re-common 10.0.39__py3-none-any.whl → 10.0.40__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- re_common/baselibrary/__init__.py +4 -4
- re_common/baselibrary/baseabs/__init__.py +6 -6
- re_common/baselibrary/baseabs/baseabs.py +26 -26
- re_common/baselibrary/database/mbuilder.py +132 -132
- re_common/baselibrary/database/moudle.py +93 -93
- re_common/baselibrary/database/msqlite3.py +194 -194
- re_common/baselibrary/database/mysql.py +169 -169
- re_common/baselibrary/database/sql_factory.py +26 -26
- re_common/baselibrary/mthread/MThreadingRun.py +486 -486
- re_common/baselibrary/mthread/MThreadingRunEvent.py +349 -349
- re_common/baselibrary/mthread/__init__.py +2 -2
- re_common/baselibrary/mthread/mythreading.py +695 -695
- re_common/baselibrary/pakge_other/socks.py +404 -404
- re_common/baselibrary/readconfig/config_factory.py +18 -18
- re_common/baselibrary/readconfig/ini_config.py +317 -317
- re_common/baselibrary/readconfig/toml_config.py +49 -49
- re_common/baselibrary/temporary/envdata.py +36 -36
- re_common/baselibrary/tools/all_requests/aiohttp_request.py +118 -118
- re_common/baselibrary/tools/all_requests/httpx_requet.py +102 -102
- re_common/baselibrary/tools/all_requests/mrequest.py +412 -412
- re_common/baselibrary/tools/all_requests/requests_request.py +81 -81
- re_common/baselibrary/tools/batch_compre/bijiao_batch.py +31 -31
- re_common/baselibrary/tools/contrast_db3.py +123 -123
- re_common/baselibrary/tools/copy_file.py +39 -39
- re_common/baselibrary/tools/db3_2_sizedb3.py +102 -102
- re_common/baselibrary/tools/foreachgz.py +39 -39
- re_common/baselibrary/tools/get_attr.py +10 -10
- re_common/baselibrary/tools/image_to_pdf.py +61 -61
- re_common/baselibrary/tools/java_code_deal.py +139 -139
- re_common/baselibrary/tools/javacode.py +79 -79
- re_common/baselibrary/tools/mdb_db3.py +48 -48
- re_common/baselibrary/tools/merge_file.py +171 -171
- re_common/baselibrary/tools/merge_gz_file.py +165 -165
- re_common/baselibrary/tools/mhdfstools/down_hdfs_files.py +42 -42
- re_common/baselibrary/tools/mhdfstools/hdfst.py +42 -42
- re_common/baselibrary/tools/mhdfstools/up_hdfs_files.py +38 -38
- re_common/baselibrary/tools/mongo_tools.py +50 -50
- re_common/baselibrary/tools/move_file.py +170 -170
- re_common/baselibrary/tools/move_mongo/mongo_table_to_file.py +63 -63
- re_common/baselibrary/tools/move_mongo/move_mongo_table.py +354 -354
- re_common/baselibrary/tools/move_mongo/use_mttf.py +18 -18
- re_common/baselibrary/tools/move_mongo/use_mv.py +93 -93
- re_common/baselibrary/tools/mpandas/mpandasreadexcel.py +125 -125
- re_common/baselibrary/tools/mpandas/pandas_visualization.py +7 -7
- re_common/baselibrary/tools/myparsel.py +104 -104
- re_common/baselibrary/tools/rename_dir_file.py +37 -37
- re_common/baselibrary/tools/sequoiadb_utils.py +398 -398
- re_common/baselibrary/tools/split_line_to_many.py +25 -25
- re_common/baselibrary/tools/stringtodicts.py +33 -33
- re_common/baselibrary/tools/workwechant_bot.py +84 -84
- re_common/baselibrary/utils/baseaiohttp.py +296 -296
- re_common/baselibrary/utils/baseaiomysql.py +87 -87
- re_common/baselibrary/utils/baseallstep.py +191 -191
- re_common/baselibrary/utils/baseavro.py +19 -19
- re_common/baselibrary/utils/baseboto3.py +291 -291
- re_common/baselibrary/utils/basecsv.py +32 -32
- re_common/baselibrary/utils/basedict.py +133 -133
- re_common/baselibrary/utils/basedir.py +241 -241
- re_common/baselibrary/utils/baseencode.py +351 -351
- re_common/baselibrary/utils/baseencoding.py +28 -28
- re_common/baselibrary/utils/baseesdsl.py +86 -86
- re_common/baselibrary/utils/baseexcel.py +264 -264
- re_common/baselibrary/utils/baseexcept.py +109 -109
- re_common/baselibrary/utils/basefile.py +654 -654
- re_common/baselibrary/utils/baseftp.py +214 -214
- re_common/baselibrary/utils/basegzip.py +60 -60
- re_common/baselibrary/utils/basehdfs.py +135 -135
- re_common/baselibrary/utils/basehttpx.py +268 -268
- re_common/baselibrary/utils/baseip.py +87 -87
- re_common/baselibrary/utils/basejson.py +2 -2
- re_common/baselibrary/utils/baselist.py +32 -32
- re_common/baselibrary/utils/basemotor.py +190 -190
- re_common/baselibrary/utils/basemssql.py +98 -98
- re_common/baselibrary/utils/baseodbc.py +113 -113
- re_common/baselibrary/utils/basepandas.py +302 -302
- re_common/baselibrary/utils/basepeewee.py +11 -11
- re_common/baselibrary/utils/basepika.py +180 -180
- re_common/baselibrary/utils/basepydash.py +143 -143
- re_common/baselibrary/utils/basepymongo.py +230 -230
- re_common/baselibrary/utils/basequeue.py +22 -22
- re_common/baselibrary/utils/baserar.py +57 -57
- re_common/baselibrary/utils/baserequest.py +279 -279
- re_common/baselibrary/utils/baseset.py +8 -8
- re_common/baselibrary/utils/basesmb.py +403 -403
- re_common/baselibrary/utils/basestring.py +382 -382
- re_common/baselibrary/utils/basetime.py +320 -320
- re_common/baselibrary/utils/baseurl.py +121 -121
- re_common/baselibrary/utils/basezip.py +57 -57
- re_common/baselibrary/utils/core/__init__.py +7 -7
- re_common/baselibrary/utils/core/bottomutils.py +18 -18
- re_common/baselibrary/utils/core/mdeprecated.py +327 -327
- re_common/baselibrary/utils/core/mlamada.py +16 -16
- re_common/baselibrary/utils/core/msginfo.py +25 -25
- re_common/baselibrary/utils/core/requests_core.py +103 -103
- re_common/baselibrary/utils/fateadm.py +429 -429
- re_common/baselibrary/utils/importfun.py +123 -123
- re_common/baselibrary/utils/mfaker.py +57 -57
- re_common/baselibrary/utils/my_abc/__init__.py +3 -3
- re_common/baselibrary/utils/my_abc/better_abc.py +32 -32
- re_common/baselibrary/utils/mylogger.py +414 -414
- re_common/baselibrary/utils/myredisclient.py +861 -861
- re_common/baselibrary/utils/pipupgrade.py +21 -21
- re_common/baselibrary/utils/ringlist.py +85 -85
- re_common/baselibrary/utils/version_compare.py +36 -36
- re_common/baselibrary/utils/ydmhttp.py +126 -126
- re_common/facade/lazy_import.py +11 -11
- re_common/facade/loggerfacade.py +25 -25
- re_common/facade/mysqlfacade.py +467 -467
- re_common/facade/now.py +31 -31
- re_common/facade/sqlite3facade.py +257 -257
- re_common/facade/use/mq_use_facade.py +83 -83
- re_common/facade/use/proxy_use_facade.py +19 -19
- re_common/libtest/base_dict_test.py +19 -19
- re_common/libtest/baseavro_test.py +13 -13
- re_common/libtest/basefile_test.py +14 -14
- re_common/libtest/basemssql_test.py +77 -77
- re_common/libtest/baseodbc_test.py +7 -7
- re_common/libtest/basepandas_test.py +38 -38
- re_common/libtest/get_attr_test/get_attr_test_settings.py +14 -14
- re_common/libtest/get_attr_test/settings.py +54 -54
- re_common/libtest/idencode_test.py +53 -53
- re_common/libtest/iniconfig_test.py +35 -35
- re_common/libtest/ip_test.py +34 -34
- re_common/libtest/merge_file_test.py +20 -20
- re_common/libtest/mfaker_test.py +8 -8
- re_common/libtest/mm3_test.py +31 -31
- re_common/libtest/mylogger_test.py +88 -88
- re_common/libtest/myparsel_test.py +27 -27
- re_common/libtest/mysql_test.py +151 -151
- re_common/libtest/pymongo_test.py +21 -21
- re_common/libtest/split_test.py +11 -11
- re_common/libtest/sqlite3_merge_test.py +5 -5
- re_common/libtest/sqlite3_test.py +34 -34
- re_common/libtest/tomlconfig_test.py +30 -30
- re_common/libtest/use_tools_test/__init__.py +2 -2
- re_common/libtest/user/__init__.py +4 -4
- re_common/studio/__init__.py +4 -4
- re_common/studio/assignment_expressions.py +36 -36
- re_common/studio/mydash/test1.py +18 -18
- re_common/studio/pydashstudio/first.py +9 -9
- re_common/studio/streamlitstudio/first_app.py +65 -65
- re_common/studio/streamlitstudio/uber_pickups.py +23 -23
- re_common/studio/test.py +18 -18
- re_common/v2/baselibrary/business_utils/BusinessStringUtil.py +219 -219
- re_common/v2/baselibrary/business_utils/baseencodeid.py +100 -100
- re_common/v2/baselibrary/business_utils/full_doi_path.py +116 -116
- re_common/v2/baselibrary/business_utils/rel_tools.py +6 -6
- re_common/v2/baselibrary/decorators/utils.py +59 -59
- re_common/v2/baselibrary/helpers/search_packge/NearestNeighbors_test.py +105 -105
- re_common/v2/baselibrary/helpers/search_packge/fit_text_match.py +253 -253
- re_common/v2/baselibrary/helpers/search_packge/scikit_learn_text_matcher.py +260 -260
- re_common/v2/baselibrary/helpers/search_packge/test.py +1 -1
- re_common/v2/baselibrary/s3object/baseboto3.py +230 -230
- re_common/v2/baselibrary/tools/WeChatRobot.py +95 -95
- re_common/v2/baselibrary/tools/ac_ahocorasick.py +75 -75
- re_common/v2/baselibrary/tools/concurrency.py +35 -35
- re_common/v2/baselibrary/tools/data_processer/base.py +53 -53
- re_common/v2/baselibrary/tools/data_processer/data_processer.py +508 -508
- re_common/v2/baselibrary/tools/data_processer/data_reader.py +187 -187
- re_common/v2/baselibrary/tools/data_processer/data_writer.py +38 -38
- re_common/v2/baselibrary/tools/dict_tools.py +44 -44
- re_common/v2/baselibrary/tools/dolphinscheduler.py +187 -187
- re_common/v2/baselibrary/tools/hdfs_base_processor.py +204 -204
- re_common/v2/baselibrary/tools/hdfs_bulk_processor.py +67 -67
- re_common/v2/baselibrary/tools/hdfs_data_processer.py +338 -338
- re_common/v2/baselibrary/tools/hdfs_line_processor.py +74 -74
- re_common/v2/baselibrary/tools/list_tools.py +69 -69
- re_common/v2/baselibrary/tools/resume_tracker.py +94 -94
- re_common/v2/baselibrary/tools/search_hash_tools.py +54 -54
- re_common/v2/baselibrary/tools/text_matcher.py +326 -326
- re_common/v2/baselibrary/tools/unionfind_tools.py +60 -60
- re_common/v2/baselibrary/utils/BusinessStringUtil.py +196 -196
- re_common/v2/baselibrary/utils/api_net_utils.py +270 -270
- re_common/v2/baselibrary/utils/author_smi.py +361 -361
- re_common/v2/baselibrary/utils/base_string_similarity.py +158 -158
- re_common/v2/baselibrary/utils/basedict.py +37 -37
- re_common/v2/baselibrary/utils/basehdfs.py +163 -163
- re_common/v2/baselibrary/utils/basepika.py +180 -180
- re_common/v2/baselibrary/utils/basetime.py +77 -77
- re_common/v2/baselibrary/utils/db.py +156 -156
- re_common/v2/baselibrary/utils/elasticsearch.py +46 -0
- re_common/v2/baselibrary/utils/json_cls.py +16 -16
- re_common/v2/baselibrary/utils/mq.py +83 -83
- re_common/v2/baselibrary/utils/n_ary_expression_tree.py +243 -243
- re_common/v2/baselibrary/utils/string_bool.py +186 -186
- re_common/v2/baselibrary/utils/string_clear.py +246 -246
- re_common/v2/baselibrary/utils/string_smi.py +18 -18
- re_common/v2/baselibrary/utils/stringutils.py +271 -271
- re_common/vip/base_step_process.py +11 -11
- re_common/vip/baseencodeid.py +90 -90
- re_common/vip/changetaskname.py +28 -28
- re_common/vip/core_var.py +24 -24
- re_common/vip/mmh3Hash.py +89 -89
- re_common/vip/proxy/allproxys.py +127 -127
- re_common/vip/proxy/allproxys_thread.py +159 -159
- re_common/vip/proxy/cnki_proxy.py +153 -153
- re_common/vip/proxy/kuaidaili.py +87 -87
- re_common/vip/proxy/proxy_all.py +113 -113
- re_common/vip/proxy/update_kuaidaili_0.py +42 -42
- re_common/vip/proxy/wanfang_proxy.py +152 -152
- re_common/vip/proxy/wp_proxy_all.py +181 -181
- re_common/vip/read_rawid_to_txt.py +91 -91
- re_common/vip/title/__init__.py +5 -5
- re_common/vip/title/transform/TransformBookTitleToZt.py +125 -125
- re_common/vip/title/transform/TransformConferenceTitleToZt.py +139 -139
- re_common/vip/title/transform/TransformCstadTitleToZt.py +195 -195
- re_common/vip/title/transform/TransformJournalTitleToZt.py +203 -203
- re_common/vip/title/transform/TransformPatentTitleToZt.py +132 -132
- re_common/vip/title/transform/TransformRegulationTitleToZt.py +114 -114
- re_common/vip/title/transform/TransformStandardTitleToZt.py +135 -135
- re_common/vip/title/transform/TransformThesisTitleToZt.py +135 -135
- re_common/vip/title/transform/__init__.py +10 -10
- {re_common-10.0.39.dist-info → re_common-10.0.40.dist-info}/LICENSE +201 -201
- {re_common-10.0.39.dist-info → re_common-10.0.40.dist-info}/METADATA +24 -16
- re_common-10.0.40.dist-info/RECORD +249 -0
- {re_common-10.0.39.dist-info → re_common-10.0.40.dist-info}/WHEEL +1 -1
- re_common-10.0.39.dist-info/RECORD +0 -248
- {re_common-10.0.39.dist-info → re_common-10.0.40.dist-info}/top_level.txt +0 -0
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
from re_common.baselibrary.utils.basemotor import BaseMotor
|
|
4
|
-
from re_common.baselibrary.utils.basepymongo import BasePyMongo
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class MongoTools(object):
|
|
8
|
-
def __init__(self, conn_str, db_name, col):
|
|
9
|
-
self.conn_str = conn_str
|
|
10
|
-
self.db_name = db_name
|
|
11
|
-
self.col = col
|
|
12
|
-
self.bs_conn = None
|
|
13
|
-
|
|
14
|
-
def conn_mongo_base(self):
|
|
15
|
-
self.bs_conn = BasePyMongo(self.conn_str)
|
|
16
|
-
self.bs_conn.use_db(self.db_name)
|
|
17
|
-
self.bs_conn.create_col(self.col)
|
|
18
|
-
|
|
19
|
-
def conn_mongo_motor(self):
|
|
20
|
-
self.bs_conn = BaseMotor()
|
|
21
|
-
self.bs_conn.AsyncIOMotorClient(self.conn_str, self.db_name)
|
|
22
|
-
self.bs_conn.get_col(self.col)
|
|
23
|
-
|
|
24
|
-
def get_first_id(self, query):
|
|
25
|
-
for item in self.bs_conn.find({"sub_db_id": "00075", "_id": {"$lt": ""}},
|
|
26
|
-
{"_id": 1}).skip(0).limit(1):
|
|
27
|
-
return item["_id"]
|
|
28
|
-
|
|
29
|
-
def get_ids(self, ids, query):
|
|
30
|
-
count = 0
|
|
31
|
-
while True:
|
|
32
|
-
lists = []
|
|
33
|
-
query_temp = query.update({"_id": {"$gt": ids}})
|
|
34
|
-
for i in self.bs_conn.find(query_temp, {"_id": 1}).sort([("_id", 1)]).limit(1000000):
|
|
35
|
-
count = count + 1
|
|
36
|
-
ids = i["_id"]
|
|
37
|
-
lists.append((i["_id"]))
|
|
38
|
-
if len(lists) % 10000 == 1:
|
|
39
|
-
print(len(lists))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if __name__ == "__main__":
|
|
43
|
-
# mt = MongoTools(
|
|
44
|
-
# conn_str="mongodb://datahouse:vipdatacenter@192.168.31.243:32920/data_warehouse.base_obj_meta_a?authSource=data_warehouse",
|
|
45
|
-
# db_name="data_warehouse", col="base_obj_meta_a")
|
|
46
|
-
mt = MongoTools(
|
|
47
|
-
conn_str="mongodb://datahouse:vipdatacenter@192.168.31.208:32920,192.168.31.206:32920,192.168.31.243:32920/data_warehouse.base_obj_meta_a?authSource=data_warehouse",
|
|
48
|
-
db_name="data_warehouse", col="base_obj_meta_a")
|
|
49
|
-
mt.conn_mongo_base()
|
|
50
|
-
print(mt.get_first_id({"sub_db_id": "00075"}))
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
from re_common.baselibrary.utils.basemotor import BaseMotor
|
|
4
|
+
from re_common.baselibrary.utils.basepymongo import BasePyMongo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MongoTools(object):
|
|
8
|
+
def __init__(self, conn_str, db_name, col):
|
|
9
|
+
self.conn_str = conn_str
|
|
10
|
+
self.db_name = db_name
|
|
11
|
+
self.col = col
|
|
12
|
+
self.bs_conn = None
|
|
13
|
+
|
|
14
|
+
def conn_mongo_base(self):
|
|
15
|
+
self.bs_conn = BasePyMongo(self.conn_str)
|
|
16
|
+
self.bs_conn.use_db(self.db_name)
|
|
17
|
+
self.bs_conn.create_col(self.col)
|
|
18
|
+
|
|
19
|
+
def conn_mongo_motor(self):
|
|
20
|
+
self.bs_conn = BaseMotor()
|
|
21
|
+
self.bs_conn.AsyncIOMotorClient(self.conn_str, self.db_name)
|
|
22
|
+
self.bs_conn.get_col(self.col)
|
|
23
|
+
|
|
24
|
+
def get_first_id(self, query):
|
|
25
|
+
for item in self.bs_conn.find({"sub_db_id": "00075", "_id": {"$lt": ""}},
|
|
26
|
+
{"_id": 1}).skip(0).limit(1):
|
|
27
|
+
return item["_id"]
|
|
28
|
+
|
|
29
|
+
def get_ids(self, ids, query):
|
|
30
|
+
count = 0
|
|
31
|
+
while True:
|
|
32
|
+
lists = []
|
|
33
|
+
query_temp = query.update({"_id": {"$gt": ids}})
|
|
34
|
+
for i in self.bs_conn.find(query_temp, {"_id": 1}).sort([("_id", 1)]).limit(1000000):
|
|
35
|
+
count = count + 1
|
|
36
|
+
ids = i["_id"]
|
|
37
|
+
lists.append((i["_id"]))
|
|
38
|
+
if len(lists) % 10000 == 1:
|
|
39
|
+
print(len(lists))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
# mt = MongoTools(
|
|
44
|
+
# conn_str="mongodb://datahouse:vipdatacenter@192.168.31.243:32920/data_warehouse.base_obj_meta_a?authSource=data_warehouse",
|
|
45
|
+
# db_name="data_warehouse", col="base_obj_meta_a")
|
|
46
|
+
mt = MongoTools(
|
|
47
|
+
conn_str="mongodb://datahouse:vipdatacenter@192.168.31.208:32920,192.168.31.206:32920,192.168.31.243:32920/data_warehouse.base_obj_meta_a?authSource=data_warehouse",
|
|
48
|
+
db_name="data_warehouse", col="base_obj_meta_a")
|
|
49
|
+
mt.conn_mongo_base()
|
|
50
|
+
print(mt.get_first_id({"sub_db_id": "00075"}))
|
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
from re_common.baselibrary.mthread.MThreadingRun import MThreadingRun2
|
|
4
|
-
from re_common.baselibrary.mthread.mythreading import ThreadInfo
|
|
5
|
-
from re_common.baselibrary.utils.basedir import BaseDir
|
|
6
|
-
from re_common.baselibrary.utils.basefile import BaseFile
|
|
7
|
-
from re_common.baselibrary.utils.basequeue import BaseQueue
|
|
8
|
-
from re_common.facade.now import get_streamlogger, get_filelogger
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def copy_one_file(fullname, sources_path, dst_path):
|
|
12
|
-
"""
|
|
13
|
-
复制文件 不会删除
|
|
14
|
-
:param fullname:
|
|
15
|
-
:param sources_path:
|
|
16
|
-
:param dst_path:
|
|
17
|
-
:return:
|
|
18
|
-
"""
|
|
19
|
-
fullname_size = BaseFile.get_file_size(fullname)
|
|
20
|
-
# 替换前面的路径得到新文件的路劲
|
|
21
|
-
dst_file = fullname.replace(sources_path, dst_path)
|
|
22
|
-
# 目录不存在就创建目录
|
|
23
|
-
dst_dir = BaseDir.get_file_dir_absolute(dst_file)
|
|
24
|
-
BaseDir.create_dir(dst_dir)
|
|
25
|
-
|
|
26
|
-
if BaseFile.is_file_exists(dst_file):
|
|
27
|
-
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
28
|
-
if fullname_size == dst_dir_size:
|
|
29
|
-
return True
|
|
30
|
-
# 复制文件
|
|
31
|
-
BaseFile.copy_file_to_file(fullname, dst_file)
|
|
32
|
-
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
33
|
-
# 文件大小一致才删除源文件
|
|
34
|
-
# 大小一致性对比不能用于windows 和 liunx之间的传输,两者会存在差异性
|
|
35
|
-
print(fullname_size,dst_dir_size)
|
|
36
|
-
if fullname_size == dst_dir_size:
|
|
37
|
-
return True
|
|
38
|
-
else:
|
|
39
|
-
return False
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def move_one_file(fullname, sources_path, dst_path):
|
|
43
|
-
"""
|
|
44
|
-
移动文件,会删除源文件
|
|
45
|
-
:param fullname:
|
|
46
|
-
:param sources_path:
|
|
47
|
-
:param dst_path:
|
|
48
|
-
:return:
|
|
49
|
-
"""
|
|
50
|
-
fullname_size = BaseFile.get_file_size(fullname)
|
|
51
|
-
# 替换前面的路径得到新文件的路劲
|
|
52
|
-
dst_file = fullname.replace(sources_path, dst_path)
|
|
53
|
-
# 目录不存在就创建目录
|
|
54
|
-
dst_dir = BaseDir.get_file_dir_absolute(dst_file)
|
|
55
|
-
BaseDir.create_dir(dst_dir)
|
|
56
|
-
if BaseFile.is_file_exists(dst_file):
|
|
57
|
-
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
58
|
-
if fullname_size == dst_dir_size:
|
|
59
|
-
BaseFile.remove_file(fullname)
|
|
60
|
-
# 复制文件
|
|
61
|
-
BaseFile.copy_file_to_file(fullname, dst_file)
|
|
62
|
-
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
63
|
-
# 文件大小一致才删除源文件
|
|
64
|
-
if fullname_size == dst_dir_size:
|
|
65
|
-
BaseFile.remove_file(fullname)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def move_file(sources_path, dst_path):
|
|
69
|
-
"""
|
|
70
|
-
移动文件,会删除源文件
|
|
71
|
-
:param sources_path:
|
|
72
|
-
:param dst_path:
|
|
73
|
-
:return:
|
|
74
|
-
"""
|
|
75
|
-
k = 0
|
|
76
|
-
for fullname in BaseDir.get_dir_all_files(sources_path):
|
|
77
|
-
k += 1
|
|
78
|
-
move_one_file(fullname, sources_path, dst_path)
|
|
79
|
-
if k % 1000 == 0:
|
|
80
|
-
print("已经拷贝{}个文件".format(k))
|
|
81
|
-
print("已经拷贝{}个文件".format(k))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
class MoveFile(object):
|
|
85
|
-
|
|
86
|
-
def __init__(self):
|
|
87
|
-
self.sources_path = ''
|
|
88
|
-
self.dst_path = ''
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class MoveFileThread(MThreadingRun2):
|
|
92
|
-
def __init__(self, num, mf):
|
|
93
|
-
super(MoveFileThread, self).__init__(num)
|
|
94
|
-
self.mf = mf
|
|
95
|
-
self.k = 0
|
|
96
|
-
self.file_logger = get_filelogger(r"F:\fun2\log")
|
|
97
|
-
self.thread_pool.work_queue = BaseQueue(1000)
|
|
98
|
-
|
|
99
|
-
def create_dir(self):
|
|
100
|
-
"""
|
|
101
|
-
先创建所有目录,防止在多线程中创建目录冲突
|
|
102
|
-
:return:
|
|
103
|
-
"""
|
|
104
|
-
for dir in BaseDir.get_dir_all_dir(self.mf.sources_path):
|
|
105
|
-
new_dir = dir.replace(self.mf.sources_path, self.mf.dst_path)
|
|
106
|
-
print(new_dir)
|
|
107
|
-
BaseDir.create_dir(new_dir)
|
|
108
|
-
|
|
109
|
-
def set_task(self, threadval, *args, **kwargs):
|
|
110
|
-
self.create_dir()
|
|
111
|
-
for fullname in BaseDir.get_dir_all_files(self.mf.sources_path):
|
|
112
|
-
self.k = self.k + 1
|
|
113
|
-
self.add_job(self.func, fullname)
|
|
114
|
-
if self.k % 1000 == 0:
|
|
115
|
-
print("已经拷贝{}个文件".format(self.k))
|
|
116
|
-
while self.get_thread_stat():
|
|
117
|
-
time.sleep(1)
|
|
118
|
-
|
|
119
|
-
def get_thread_stat(self):
|
|
120
|
-
"""
|
|
121
|
-
如果是False代表所有的线程都在等待任务,说明所有工作都已经完成
|
|
122
|
-
:return:
|
|
123
|
-
"""
|
|
124
|
-
for k, v in self.thread_pool.thread_pool_dicts.items():
|
|
125
|
-
threadinfo = v
|
|
126
|
-
thread = threadinfo.get_thread()
|
|
127
|
-
if thread.runstatus is not False:
|
|
128
|
-
return True
|
|
129
|
-
return False
|
|
130
|
-
|
|
131
|
-
def deal_results(self, threadval, *args, **kwargs):
|
|
132
|
-
time.sleep(60)
|
|
133
|
-
|
|
134
|
-
def setProxy(self, threadval, proxysList=None):
|
|
135
|
-
time.sleep(60)
|
|
136
|
-
|
|
137
|
-
def is_break(self):
|
|
138
|
-
time.sleep(5)
|
|
139
|
-
if self.thread_pool.work_queue.is_empty() and self.thread_pool.result_queue.is_empty() and not self.get_thread_stat():
|
|
140
|
-
for k, v in self.thread_pool.thread_pool_dicts.items():
|
|
141
|
-
if k == self.etn.taskthreadname:
|
|
142
|
-
threadinfo = v
|
|
143
|
-
thread = threadinfo.get_thread()
|
|
144
|
-
if thread.is_alive():
|
|
145
|
-
return False
|
|
146
|
-
return True
|
|
147
|
-
else:
|
|
148
|
-
return False
|
|
149
|
-
|
|
150
|
-
def thread_pool_hook(self, threadinfo: ThreadInfo):
|
|
151
|
-
# 设置代理线程不重启,默认会重启
|
|
152
|
-
if threadinfo.get_thread_name() == self.etn.taskthreadname:
|
|
153
|
-
threadinfo.set_is_restart(False)
|
|
154
|
-
return {}
|
|
155
|
-
|
|
156
|
-
def fun(self, threadval, *args, **kwargs):
|
|
157
|
-
fullname = args[0]
|
|
158
|
-
copy_one_file(fullname, self.mf.sources_path, self.mf.dst_path)
|
|
159
|
-
# self.file_logger.info(fullname + "\n")
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if __name__ == "__main__":
|
|
163
|
-
mf = MoveFile()
|
|
164
|
-
mf.sources_path = r"F:\fun2\test_gif"
|
|
165
|
-
# mf.dst_path = r"F:\fun2\test_gif2"
|
|
166
|
-
mf.dst_path = r"\\192.168.31.123\home\cjvip\qinym\soopat\image"
|
|
167
|
-
# mf.dst_path = r"\\192.168.31.177\down_data\test"
|
|
168
|
-
|
|
169
|
-
mft = MoveFileThread(30, mf)
|
|
170
|
-
mft.run()
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
from re_common.baselibrary.mthread.MThreadingRun import MThreadingRun2
|
|
4
|
+
from re_common.baselibrary.mthread.mythreading import ThreadInfo
|
|
5
|
+
from re_common.baselibrary.utils.basedir import BaseDir
|
|
6
|
+
from re_common.baselibrary.utils.basefile import BaseFile
|
|
7
|
+
from re_common.baselibrary.utils.basequeue import BaseQueue
|
|
8
|
+
from re_common.facade.now import get_streamlogger, get_filelogger
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def copy_one_file(fullname, sources_path, dst_path):
|
|
12
|
+
"""
|
|
13
|
+
复制文件 不会删除
|
|
14
|
+
:param fullname:
|
|
15
|
+
:param sources_path:
|
|
16
|
+
:param dst_path:
|
|
17
|
+
:return:
|
|
18
|
+
"""
|
|
19
|
+
fullname_size = BaseFile.get_file_size(fullname)
|
|
20
|
+
# 替换前面的路径得到新文件的路劲
|
|
21
|
+
dst_file = fullname.replace(sources_path, dst_path)
|
|
22
|
+
# 目录不存在就创建目录
|
|
23
|
+
dst_dir = BaseDir.get_file_dir_absolute(dst_file)
|
|
24
|
+
BaseDir.create_dir(dst_dir)
|
|
25
|
+
|
|
26
|
+
if BaseFile.is_file_exists(dst_file):
|
|
27
|
+
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
28
|
+
if fullname_size == dst_dir_size:
|
|
29
|
+
return True
|
|
30
|
+
# 复制文件
|
|
31
|
+
BaseFile.copy_file_to_file(fullname, dst_file)
|
|
32
|
+
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
33
|
+
# 文件大小一致才删除源文件
|
|
34
|
+
# 大小一致性对比不能用于windows 和 liunx之间的传输,两者会存在差异性
|
|
35
|
+
print(fullname_size,dst_dir_size)
|
|
36
|
+
if fullname_size == dst_dir_size:
|
|
37
|
+
return True
|
|
38
|
+
else:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def move_one_file(fullname, sources_path, dst_path):
|
|
43
|
+
"""
|
|
44
|
+
移动文件,会删除源文件
|
|
45
|
+
:param fullname:
|
|
46
|
+
:param sources_path:
|
|
47
|
+
:param dst_path:
|
|
48
|
+
:return:
|
|
49
|
+
"""
|
|
50
|
+
fullname_size = BaseFile.get_file_size(fullname)
|
|
51
|
+
# 替换前面的路径得到新文件的路劲
|
|
52
|
+
dst_file = fullname.replace(sources_path, dst_path)
|
|
53
|
+
# 目录不存在就创建目录
|
|
54
|
+
dst_dir = BaseDir.get_file_dir_absolute(dst_file)
|
|
55
|
+
BaseDir.create_dir(dst_dir)
|
|
56
|
+
if BaseFile.is_file_exists(dst_file):
|
|
57
|
+
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
58
|
+
if fullname_size == dst_dir_size:
|
|
59
|
+
BaseFile.remove_file(fullname)
|
|
60
|
+
# 复制文件
|
|
61
|
+
BaseFile.copy_file_to_file(fullname, dst_file)
|
|
62
|
+
dst_dir_size = BaseFile.get_file_size(dst_file)
|
|
63
|
+
# 文件大小一致才删除源文件
|
|
64
|
+
if fullname_size == dst_dir_size:
|
|
65
|
+
BaseFile.remove_file(fullname)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def move_file(sources_path, dst_path):
|
|
69
|
+
"""
|
|
70
|
+
移动文件,会删除源文件
|
|
71
|
+
:param sources_path:
|
|
72
|
+
:param dst_path:
|
|
73
|
+
:return:
|
|
74
|
+
"""
|
|
75
|
+
k = 0
|
|
76
|
+
for fullname in BaseDir.get_dir_all_files(sources_path):
|
|
77
|
+
k += 1
|
|
78
|
+
move_one_file(fullname, sources_path, dst_path)
|
|
79
|
+
if k % 1000 == 0:
|
|
80
|
+
print("已经拷贝{}个文件".format(k))
|
|
81
|
+
print("已经拷贝{}个文件".format(k))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class MoveFile(object):
|
|
85
|
+
|
|
86
|
+
def __init__(self):
|
|
87
|
+
self.sources_path = ''
|
|
88
|
+
self.dst_path = ''
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class MoveFileThread(MThreadingRun2):
|
|
92
|
+
def __init__(self, num, mf):
|
|
93
|
+
super(MoveFileThread, self).__init__(num)
|
|
94
|
+
self.mf = mf
|
|
95
|
+
self.k = 0
|
|
96
|
+
self.file_logger = get_filelogger(r"F:\fun2\log")
|
|
97
|
+
self.thread_pool.work_queue = BaseQueue(1000)
|
|
98
|
+
|
|
99
|
+
def create_dir(self):
|
|
100
|
+
"""
|
|
101
|
+
先创建所有目录,防止在多线程中创建目录冲突
|
|
102
|
+
:return:
|
|
103
|
+
"""
|
|
104
|
+
for dir in BaseDir.get_dir_all_dir(self.mf.sources_path):
|
|
105
|
+
new_dir = dir.replace(self.mf.sources_path, self.mf.dst_path)
|
|
106
|
+
print(new_dir)
|
|
107
|
+
BaseDir.create_dir(new_dir)
|
|
108
|
+
|
|
109
|
+
def set_task(self, threadval, *args, **kwargs):
|
|
110
|
+
self.create_dir()
|
|
111
|
+
for fullname in BaseDir.get_dir_all_files(self.mf.sources_path):
|
|
112
|
+
self.k = self.k + 1
|
|
113
|
+
self.add_job(self.func, fullname)
|
|
114
|
+
if self.k % 1000 == 0:
|
|
115
|
+
print("已经拷贝{}个文件".format(self.k))
|
|
116
|
+
while self.get_thread_stat():
|
|
117
|
+
time.sleep(1)
|
|
118
|
+
|
|
119
|
+
def get_thread_stat(self):
|
|
120
|
+
"""
|
|
121
|
+
如果是False代表所有的线程都在等待任务,说明所有工作都已经完成
|
|
122
|
+
:return:
|
|
123
|
+
"""
|
|
124
|
+
for k, v in self.thread_pool.thread_pool_dicts.items():
|
|
125
|
+
threadinfo = v
|
|
126
|
+
thread = threadinfo.get_thread()
|
|
127
|
+
if thread.runstatus is not False:
|
|
128
|
+
return True
|
|
129
|
+
return False
|
|
130
|
+
|
|
131
|
+
def deal_results(self, threadval, *args, **kwargs):
|
|
132
|
+
time.sleep(60)
|
|
133
|
+
|
|
134
|
+
def setProxy(self, threadval, proxysList=None):
|
|
135
|
+
time.sleep(60)
|
|
136
|
+
|
|
137
|
+
def is_break(self):
|
|
138
|
+
time.sleep(5)
|
|
139
|
+
if self.thread_pool.work_queue.is_empty() and self.thread_pool.result_queue.is_empty() and not self.get_thread_stat():
|
|
140
|
+
for k, v in self.thread_pool.thread_pool_dicts.items():
|
|
141
|
+
if k == self.etn.taskthreadname:
|
|
142
|
+
threadinfo = v
|
|
143
|
+
thread = threadinfo.get_thread()
|
|
144
|
+
if thread.is_alive():
|
|
145
|
+
return False
|
|
146
|
+
return True
|
|
147
|
+
else:
|
|
148
|
+
return False
|
|
149
|
+
|
|
150
|
+
def thread_pool_hook(self, threadinfo: ThreadInfo):
|
|
151
|
+
# 设置代理线程不重启,默认会重启
|
|
152
|
+
if threadinfo.get_thread_name() == self.etn.taskthreadname:
|
|
153
|
+
threadinfo.set_is_restart(False)
|
|
154
|
+
return {}
|
|
155
|
+
|
|
156
|
+
def fun(self, threadval, *args, **kwargs):
|
|
157
|
+
fullname = args[0]
|
|
158
|
+
copy_one_file(fullname, self.mf.sources_path, self.mf.dst_path)
|
|
159
|
+
# self.file_logger.info(fullname + "\n")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == "__main__":
|
|
163
|
+
mf = MoveFile()
|
|
164
|
+
mf.sources_path = r"F:\fun2\test_gif"
|
|
165
|
+
# mf.dst_path = r"F:\fun2\test_gif2"
|
|
166
|
+
mf.dst_path = r"\\192.168.31.123\home\cjvip\qinym\soopat\image"
|
|
167
|
+
# mf.dst_path = r"\\192.168.31.177\down_data\test"
|
|
168
|
+
|
|
169
|
+
mft = MoveFileThread(30, mf)
|
|
170
|
+
mft.run()
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import gzip
|
|
3
|
-
import json
|
|
4
|
-
|
|
5
|
-
from re_common.baselibrary.utils.basefile import BaseFile
|
|
6
|
-
from re_common.baselibrary.utils.basegzip import BaseGzip
|
|
7
|
-
from re_common.baselibrary.utils.basemotor import BaseMotor
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Configs(object):
|
|
11
|
-
|
|
12
|
-
def __init__(self):
|
|
13
|
-
self.mgdb_conn_motor = "mongodb://cjrw:vipdatacenter@192.168.31.243:32920,192.168.31.206:32920,192.168.31.208:32920/?authSource=htmljson"
|
|
14
|
-
self.mgdb_db = "htmljson"
|
|
15
|
-
self.mgdb_col = "other"
|
|
16
|
-
self.filepath = r"F:\fun3\up\detail\mbalib.big_json.gz"
|
|
17
|
-
self.query = {}
|
|
18
|
-
self.feild = None
|
|
19
|
-
self.one_file_num = 100000
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class MongoToFile(object):
|
|
23
|
-
def __init__(self, conf):
|
|
24
|
-
self.conf = conf
|
|
25
|
-
self.file_open = None
|
|
26
|
-
self.i = 0
|
|
27
|
-
|
|
28
|
-
def init_conn_mongodb(self):
|
|
29
|
-
self.bs = BaseMotor()
|
|
30
|
-
self.bs.AsyncIOMotorClient(
|
|
31
|
-
self.conf.mgdb_conn_motor,
|
|
32
|
-
self.conf.mgdb_db)
|
|
33
|
-
self.bs.get_col(self.conf.mgdb_col)
|
|
34
|
-
|
|
35
|
-
def open_file(self):
|
|
36
|
-
i = BaseGzip.get_gz_line_num(self.conf.filepath)
|
|
37
|
-
if i >= self.conf.one_file_num:
|
|
38
|
-
self.conf.filepath = BaseFile.get_new_filename(self.conf.filepath)
|
|
39
|
-
self.file_open = gzip.open(self.conf.filepath, "wb")
|
|
40
|
-
|
|
41
|
-
def close_file(self):
|
|
42
|
-
self.file_open.close()
|
|
43
|
-
|
|
44
|
-
def asyncio_run(self):
|
|
45
|
-
asyncio.get_event_loop().run_until_complete(
|
|
46
|
-
self.bs.find(self.dic_deal, self.conf.query, self.conf.feild))
|
|
47
|
-
self.close_file()
|
|
48
|
-
|
|
49
|
-
def hook_doc(self, doc):
|
|
50
|
-
return doc
|
|
51
|
-
|
|
52
|
-
async def dic_deal(self, doc):
|
|
53
|
-
doc = self.hook_doc(doc)
|
|
54
|
-
line = json.dumps(doc, ensure_ascii=False) + '\n'
|
|
55
|
-
lines = line.encode()
|
|
56
|
-
self.file_open.write(lines)
|
|
57
|
-
self.i = self.i + 1
|
|
58
|
-
print(self.i)
|
|
59
|
-
if self.i >= self.conf.one_file_num:
|
|
60
|
-
self.close_file()
|
|
61
|
-
self.conf.filepath = BaseFile.get_new_filename(self.conf.filepath)
|
|
62
|
-
self.open_file()
|
|
63
|
-
self.i = 0
|
|
1
|
+
import asyncio
|
|
2
|
+
import gzip
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from re_common.baselibrary.utils.basefile import BaseFile
|
|
6
|
+
from re_common.baselibrary.utils.basegzip import BaseGzip
|
|
7
|
+
from re_common.baselibrary.utils.basemotor import BaseMotor
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Configs(object):
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.mgdb_conn_motor = "mongodb://cjrw:vipdatacenter@192.168.31.243:32920,192.168.31.206:32920,192.168.31.208:32920/?authSource=htmljson"
|
|
14
|
+
self.mgdb_db = "htmljson"
|
|
15
|
+
self.mgdb_col = "other"
|
|
16
|
+
self.filepath = r"F:\fun3\up\detail\mbalib.big_json.gz"
|
|
17
|
+
self.query = {}
|
|
18
|
+
self.feild = None
|
|
19
|
+
self.one_file_num = 100000
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MongoToFile(object):
|
|
23
|
+
def __init__(self, conf):
|
|
24
|
+
self.conf = conf
|
|
25
|
+
self.file_open = None
|
|
26
|
+
self.i = 0
|
|
27
|
+
|
|
28
|
+
def init_conn_mongodb(self):
|
|
29
|
+
self.bs = BaseMotor()
|
|
30
|
+
self.bs.AsyncIOMotorClient(
|
|
31
|
+
self.conf.mgdb_conn_motor,
|
|
32
|
+
self.conf.mgdb_db)
|
|
33
|
+
self.bs.get_col(self.conf.mgdb_col)
|
|
34
|
+
|
|
35
|
+
def open_file(self):
|
|
36
|
+
i = BaseGzip.get_gz_line_num(self.conf.filepath)
|
|
37
|
+
if i >= self.conf.one_file_num:
|
|
38
|
+
self.conf.filepath = BaseFile.get_new_filename(self.conf.filepath)
|
|
39
|
+
self.file_open = gzip.open(self.conf.filepath, "wb")
|
|
40
|
+
|
|
41
|
+
def close_file(self):
|
|
42
|
+
self.file_open.close()
|
|
43
|
+
|
|
44
|
+
def asyncio_run(self):
|
|
45
|
+
asyncio.get_event_loop().run_until_complete(
|
|
46
|
+
self.bs.find(self.dic_deal, self.conf.query, self.conf.feild))
|
|
47
|
+
self.close_file()
|
|
48
|
+
|
|
49
|
+
def hook_doc(self, doc):
|
|
50
|
+
return doc
|
|
51
|
+
|
|
52
|
+
async def dic_deal(self, doc):
|
|
53
|
+
doc = self.hook_doc(doc)
|
|
54
|
+
line = json.dumps(doc, ensure_ascii=False) + '\n'
|
|
55
|
+
lines = line.encode()
|
|
56
|
+
self.file_open.write(lines)
|
|
57
|
+
self.i = self.i + 1
|
|
58
|
+
print(self.i)
|
|
59
|
+
if self.i >= self.conf.one_file_num:
|
|
60
|
+
self.close_file()
|
|
61
|
+
self.conf.filepath = BaseFile.get_new_filename(self.conf.filepath)
|
|
62
|
+
self.open_file()
|
|
63
|
+
self.i = 0
|