-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEUMETSATMain.py
62 lines (51 loc) · 2.2 KB
/
EUMETSATMain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
# @Time :2023/12/2 14:25
# @Author :小 y 同 学
# @公众号 :小y只会写bug
# @CSDN :https://blog.csdn.net/weixin_64989228?type=blog
import multiprocessing
from ClassEumdac import *
# todo 设置参数
consumer_key = 'xxx' # todo 设置key
consumer_secret = 'xxx' # todo 设置secret
products_url_path = "./products_url.txt" # todo 设置产品信息文件保存路径
products_file_path = "./products_all.txt" # todo 设置产品信息文件保存路径
download_path = "./test" # todo 设置产品下载保存路径
IPPort = "替换位置一:替换位置二" # todo 设置代理
multiN = 5 # todo 进程个数
proxies = {
"http": IPPort,
"https": IPPort
}
user = UserInfo(consumer_key, consumer_secret, proxies=proxies)
save_param = SaveParam(download_path)
UserPrint.PrintRemind("Initialization completed!")
def multi(url):
global user, save_param, proxies
product = ProductInfo(url, user, save_param)
product.DownloadFile(proxies)
if __name__ == '__main__':
flag = input("Whether product information files need to be updated? (y/n):")
ProductsInfoFile = ProductsInfoFile()
if flag == 'y' or flag == 'Y':
UserPrint.PrintRemind(f"Creating a product information file, Path: {products_file_path}")
f = open(products_url_path, 'r')
url = f.read().strip()
f.close()
ProductsInfoFile.CreateProductsFile(url, products_file_path, proxies)
UserPrint.PrintAccept(f"Product information file created successfully,Path:{products_file_path}")
# 多进程
url_list = ProductsInfoFile.ReadProductsFile(products_file_path)
stime = time.ctime()
UserPrint.PrintRemind("There are {} products in total".format(len(url_list)))
with multiprocessing.Pool(multiN) as p:
p.map(multi, url_list)
UserPrint.PrintRemind("All products have been downloaded,start time:{},end time:{}".format(stime, time.ctime()))
# # 多线程
# url_list = ReadProductsFile(products_file_path)
# stime = time.ctime()
# PrintRemind("There are {} products in total".format(len(url_list)))
# with ThreadPool(multiN) as p:
# p.map(multi, url_list)
# PrintRemind("All products have been downloaded,stime:{},etime:{}".format(stime, time.ctime()))
pass