shancx 1.9.33.163__py3-none-any.whl → 1.9.33.166__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.
- shancx/NN/__init__.py +30 -32
- shancx/__init__.py +35 -5
- shancx/wait.py +4 -5
- {shancx-1.9.33.163.dist-info → shancx-1.9.33.166.dist-info}/METADATA +1 -1
- {shancx-1.9.33.163.dist-info → shancx-1.9.33.166.dist-info}/RECORD +8 -8
- /shancx/{Path.py → path.py} +0 -0
- {shancx-1.9.33.163.dist-info → shancx-1.9.33.166.dist-info}/WHEEL +0 -0
- {shancx-1.9.33.163.dist-info → shancx-1.9.33.166.dist-info}/top_level.txt +0 -0
shancx/NN/__init__.py
CHANGED
|
@@ -11,11 +11,11 @@ __author_email__ = 'shancx@126.com'
|
|
|
11
11
|
# @Time : 2023/09/27 下午8:52
|
|
12
12
|
# @Author : shanchangxi
|
|
13
13
|
# @File : util_log.py
|
|
14
|
-
|
|
15
14
|
import logging
|
|
16
15
|
from logging.handlers import RotatingFileHandler
|
|
17
16
|
import os
|
|
18
|
-
|
|
17
|
+
from shancx import crDir
|
|
18
|
+
def _loggers(logger_name="loggers", root="./logs", phase="project", level=logging.INFO, screen=True, max_bytes=10*1024*1024, backup_count=5, overwrite=False,handlersflag=True):
|
|
19
19
|
'''set up logger with rotating file handler'''
|
|
20
20
|
l = logging.getLogger(logger_name)
|
|
21
21
|
if handlersflag:
|
|
@@ -24,9 +24,7 @@ def _loggers(logger_name="loggers", root="./logs", phase="project", level=loggin
|
|
|
24
24
|
formatter = logging.Formatter(
|
|
25
25
|
"%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s", datefmt='%Y-%m-%d %H:%M:%S')
|
|
26
26
|
log_file = os.path.join(root, '{}.log'.format(phase))
|
|
27
|
-
|
|
28
|
-
if not os.path.exists(log_dir):
|
|
29
|
-
os.makedirs(log_dir, exist_ok=True)
|
|
27
|
+
crDir(log_file)
|
|
30
28
|
# Use RotatingFileHandler with 'w' mode to overwrite log file if needed
|
|
31
29
|
mode = 'w' if overwrite else 'a'
|
|
32
30
|
fh = RotatingFileHandler(log_file, mode=mode, maxBytes=max_bytes, backupCount=backup_count)
|
|
@@ -66,30 +64,30 @@ if __name__ == "__main__":
|
|
|
66
64
|
logger.info("这是一条INFO日志")
|
|
67
65
|
'''
|
|
68
66
|
|
|
69
|
-
import os
|
|
70
|
-
from datetime import datetime
|
|
71
|
-
from shancx.NN import _loggers
|
|
72
|
-
from shancx import lock_file
|
|
73
|
-
from shancx.wait import check_lock
|
|
74
|
-
from shancx import crDir
|
|
75
|
-
logger =_loggers()
|
|
76
|
-
def check_process_data(UTC, sat_cd,basepath ="/mnt/wtx_weather_forecast/scx/test/lock_files" ):
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"""
|
|
90
|
-
flag1,file = check_process_data(UTC, "H9SEAS" )
|
|
91
|
-
if flag1:
|
|
92
|
-
|
|
93
|
-
if os.path.exists(output_path): #配合使用
|
|
94
|
-
|
|
95
|
-
"""
|
|
67
|
+
# import os
|
|
68
|
+
# from datetime import datetime
|
|
69
|
+
# from shancx.NN import _loggers
|
|
70
|
+
# from shancx import lock_file
|
|
71
|
+
# from shancx.wait import check_lock
|
|
72
|
+
# from shancx import crDir
|
|
73
|
+
# logger =_loggers()
|
|
74
|
+
# def check_process_data(UTC, sat_cd,basepath ="/mnt/wtx_weather_forecast/scx/test/lock_files" ):
|
|
75
|
+
# try:
|
|
76
|
+
# UTCStr = UTC.strftime("%Y%m%d%H%M")
|
|
77
|
+
# file = f"/mnt/wtx_weather_forecast/scx/test/lock_files/{sat_cd}/{UTCStr[:4]}/{UTCStr[:8]}/File_{UTCStr}.lock"
|
|
78
|
+
# crDir(file)
|
|
79
|
+
# if not lock_file(file):
|
|
80
|
+
# if check_lock(file):
|
|
81
|
+
# logger.info("data is making or maked")
|
|
82
|
+
# return True ,file
|
|
83
|
+
# return False,file
|
|
84
|
+
# except Exception as e:
|
|
85
|
+
# logger.error(f"Error in check_and_process_data: {str(e)}")
|
|
86
|
+
# return False,file
|
|
87
|
+
# """
|
|
88
|
+
# flag1,file = check_process_data(UTC, "H9SEAS" )
|
|
89
|
+
# if flag1:
|
|
90
|
+
# sys.exit()
|
|
91
|
+
# if os.path.exists(output_path): #配合使用
|
|
92
|
+
# sys.exit()
|
|
93
|
+
# """
|
shancx/__init__.py
CHANGED
|
@@ -346,14 +346,12 @@ from pathlib import Path
|
|
|
346
346
|
def lock_file(lock_file_path):
|
|
347
347
|
if os.path.exists(lock_file_path):
|
|
348
348
|
print(f" {lock_file_path} is existded ")
|
|
349
|
-
|
|
350
|
-
return True
|
|
349
|
+
return False
|
|
351
350
|
try:
|
|
352
351
|
os.makedirs(os.path.dirname(lock_file_path), exist_ok=True)
|
|
353
352
|
with open(lock_file_path, 'w') as f:
|
|
354
353
|
f.write(f"process_id:{os.getpid()},create_time:{datetime.datetime.now()}")
|
|
355
|
-
|
|
356
|
-
return False
|
|
354
|
+
return True
|
|
357
355
|
except Exception as e:
|
|
358
356
|
print(f"创建锁文件失败 create lock failed : {e}")
|
|
359
357
|
return False
|
|
@@ -366,7 +364,39 @@ if os.path.exists(lock_file):
|
|
|
366
364
|
print(f"锁文件存在,已有程序在处理时次 {utc_time_str},跳过")
|
|
367
365
|
return False
|
|
368
366
|
"""
|
|
369
|
-
|
|
367
|
+
import os
|
|
368
|
+
import time
|
|
369
|
+
def is_process_alive(pid):
|
|
370
|
+
try:
|
|
371
|
+
os.kill(pid, 0)
|
|
372
|
+
return True
|
|
373
|
+
except OSError:
|
|
374
|
+
return False
|
|
375
|
+
def check_lock(lock_file):
|
|
376
|
+
if not os.path.exists(lock_file):
|
|
377
|
+
return False
|
|
378
|
+
try:
|
|
379
|
+
with open(lock_file, 'r') as f:
|
|
380
|
+
content = f.read().strip()
|
|
381
|
+
if 'process_id:' in content and 'create_time:' in content:
|
|
382
|
+
pid_str = content.split('process_id:')[1].split(',')[0]
|
|
383
|
+
pid = int(pid_str)
|
|
384
|
+
if not is_process_alive(pid):
|
|
385
|
+
print(f"进程 {pid} 已消亡,清理锁文件")
|
|
386
|
+
os.remove(lock_file)
|
|
387
|
+
return False
|
|
388
|
+
else:
|
|
389
|
+
print(f"进程 {pid} 仍在运行,跳过执行")
|
|
390
|
+
return True
|
|
391
|
+
except Exception as e:
|
|
392
|
+
print(f"锁文件解析错误,清理: {e}")
|
|
393
|
+
os.remove(lock_file)
|
|
394
|
+
return False
|
|
395
|
+
return False
|
|
396
|
+
"""
|
|
397
|
+
if check_lock(lock_file):
|
|
398
|
+
return False
|
|
399
|
+
"""
|
|
370
400
|
import multiprocessing
|
|
371
401
|
import sys
|
|
372
402
|
from typing import Optional, Literal
|
shancx/wait.py
CHANGED
|
@@ -167,8 +167,7 @@ def is_process_alive(pid):
|
|
|
167
167
|
return False
|
|
168
168
|
def check_lock(lock_file):
|
|
169
169
|
if not os.path.exists(lock_file):
|
|
170
|
-
|
|
171
|
-
return False
|
|
170
|
+
return False
|
|
172
171
|
try:
|
|
173
172
|
with open(lock_file, 'r') as f:
|
|
174
173
|
content = f.read().strip()
|
|
@@ -176,14 +175,14 @@ def check_lock(lock_file):
|
|
|
176
175
|
pid_str = content.split('process_id:')[1].split(',')[0]
|
|
177
176
|
pid = int(pid_str)
|
|
178
177
|
if not is_process_alive(pid):
|
|
179
|
-
|
|
180
|
-
return False
|
|
178
|
+
print(f"进程 {pid} 已消亡,清理锁文件")
|
|
181
179
|
os.remove(lock_file)
|
|
182
180
|
return False
|
|
183
181
|
else:
|
|
182
|
+
print(f"进程 {pid} 仍在运行,跳过执行")
|
|
184
183
|
return True
|
|
185
184
|
except Exception as e:
|
|
186
|
-
print(f"
|
|
185
|
+
print(f"锁文件解析错误,清理: {e}")
|
|
187
186
|
os.remove(lock_file)
|
|
188
187
|
return False
|
|
189
188
|
return False
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
shancx/Command.py,sha256=XCwd3ON6QtqwEgzgIP9NpCPnqfMQ-lFxR46DilsDJck,4816
|
|
2
2
|
shancx/Inst.py,sha256=Q8dULK2djqBU0JFyhMAf1mhWzFDwx9SaAJuTIO0AWig,751
|
|
3
3
|
shancx/Lib.py,sha256=GUAspllSxk39mvj-F1Q8Ys0EcY_lQfZPRGPE7L3x4SE,977
|
|
4
|
-
shancx/Path.py,sha256=vX4A5RgdwVyIVVNZRocl18rOu1Z8YMLfDb0B92-0bE8,5334
|
|
5
4
|
shancx/Point.py,sha256=gyIomOVbNoz6SOcAhhTS26NHBeJ0TOwB-ljNsBWN1ZE,1909
|
|
6
5
|
shancx/QC.py,sha256=gVH1jAZ2tI-sDygozwfXQgLEJNJscFuzxexWXuXHWHw,2803
|
|
7
6
|
shancx/Read.py,sha256=xX4ciDoWhL9KAsN3cWvaFAOMlSVwR56AR3dSB-SBnLI,3139
|
|
8
7
|
shancx/ZR.py,sha256=5APchqVoI1G2MkrN9YJSWCwfLUygcSFIsUXSo9aq1Qg,341
|
|
9
|
-
shancx/__init__.py,sha256=
|
|
8
|
+
shancx/__init__.py,sha256=ejEaYlajqIeXfIpXzVeAIUfvBlExWhyu5pcc-SVFqW4,19744
|
|
10
9
|
shancx/args.py,sha256=Nr80vgQpT3m31_crKGf5DvofCxyERJFbqJ1sHb1BIqs,1042
|
|
11
10
|
shancx/bak.py,sha256=eKe2o1Yq7LCldoA-LXi14s_QNf1BkQsDsWJ7pDoscrw,25428
|
|
12
11
|
shancx/cmp.py,sha256=cIQv-QTl-22FJa6tmHyBu_IQmMq5LnsQGGFK5jc5hMA,893
|
|
@@ -14,9 +13,10 @@ shancx/df2database.py,sha256=h9_n9tZBWKyGKnpGPRHPSZgMn5kylX0sV5APwmi2SHM,3315
|
|
|
14
13
|
shancx/getResponse.py,sha256=QmJfa4czGCOiKb8RuCLXKE7AAKVADAptNiwn7v1tfbM,1055
|
|
15
14
|
shancx/info.py,sha256=0rk_L8Z5uj9RliaZrzT-CArH9ZObmdmcp-1RxAItL08,1122
|
|
16
15
|
shancx/netdfJU.py,sha256=96KR9NMLr2Kcs_OOMpX7QPujdWUj0GCEUIZ7_4_pBxw,7741
|
|
16
|
+
shancx/path.py,sha256=vX4A5RgdwVyIVVNZRocl18rOu1Z8YMLfDb0B92-0bE8,5334
|
|
17
17
|
shancx/sendM.py,sha256=CEpeHavseWILlfevhfOMYxYUIWhh4fCNkXGRsEjMxBE,3352
|
|
18
18
|
shancx/tool.py,sha256=T1Uwsd5vcfKLEMGq7DmhPOmsnBNZgYq-QML8W2a6KTc,1027
|
|
19
|
-
shancx/wait.py,sha256=
|
|
19
|
+
shancx/wait.py,sha256=OgT9JmEgMH7d3ir3TEksx0_Kyl_S4bkOKl50jvVpdFA,8575
|
|
20
20
|
shancx/3D/__init__.py,sha256=pDFvW1OOEW-ueXH50NJIYdWlySHZU6sr5htzHUSeROo,1000
|
|
21
21
|
shancx/Algo/Class.py,sha256=bxJ9JhIjoxl0hJfjO126YrnyHWDpxCEAZ7qcPs0Y0ic,377
|
|
22
22
|
shancx/Algo/CudaPrefetcher1.py,sha256=mUVlS3txsriET26ZMZ6DYOnyzWr8Tz6wThifzWrC7k8,3951
|
|
@@ -62,7 +62,7 @@ shancx/H9/ahisearchtable.py,sha256=e2kpz-P5npgL4gzNxn8igERJuWWIysvTNLkptr5_Zcc,9
|
|
|
62
62
|
shancx/H9/geometry.py,sha256=ZoCfgP07ANqDxyLf8uFN016DPl7QqW9pAV3sr2ekCng,95893
|
|
63
63
|
shancx/Hug/__init__.py,sha256=NvcqXM0CSwXYtTr5yj4zfkag_7PZcI5tCsIHjuLNXTQ,3040
|
|
64
64
|
shancx/Mos/__init__.py,sha256=IDlCLNN6a_mguYmRcAPcevHSDaud5ZhvYNSuASqztcE,1563
|
|
65
|
-
shancx/NN/__init__.py,sha256=
|
|
65
|
+
shancx/NN/__init__.py,sha256=TpDNbhE7-q6bQal_dSbQdPOQXXRAnb8Z6-OEEJLk7CI,3182
|
|
66
66
|
shancx/Plot/GlobMap.py,sha256=WRvZOf5bo8IfECk1-sN4g6K0CrcJhSoEJAiLvZAWDwg,13021
|
|
67
67
|
shancx/Plot/Gray2RGB.py,sha256=yDXu1xWVi7OtrS8_ExxK_ev1988kj1ZxoNCWf-kl4Zc,2734
|
|
68
68
|
shancx/Plot/__init__.py,sha256=R4pywzeVDqEWGMkWeGBAVmopgPBThiLv2RBDlGquNGc,31891
|
|
@@ -83,7 +83,7 @@ shancx/Train/multiGpu.py,sha256=D_oZeiSc7VWktpnVDwrFOC1CYZSt9rxOKY5lngE5vFg,820
|
|
|
83
83
|
shancx/Train/prepare.py,sha256=vL_8UOA66oZCBIwCICtihsGibivtNgaVJGulJxfNdn8,6793
|
|
84
84
|
shancx/Train/renet50.py,sha256=wEhYk1X96WE5zuqHqVxWLJa-A5jDNkz4z6edORNufnA,6428
|
|
85
85
|
shancx/tensBoard/__init__.py,sha256=ga2C5YyJITvvQA1ocpxna_KNFnNRJVwkTjLoIglLZUQ,993
|
|
86
|
-
shancx-1.9.33.
|
|
87
|
-
shancx-1.9.33.
|
|
88
|
-
shancx-1.9.33.
|
|
89
|
-
shancx-1.9.33.
|
|
86
|
+
shancx-1.9.33.166.dist-info/METADATA,sha256=5G1ko7A2fzRfJm1eqlLRSC1eBEaemrUAtAxxCH7YFCU,644
|
|
87
|
+
shancx-1.9.33.166.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
88
|
+
shancx-1.9.33.166.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
|
|
89
|
+
shancx-1.9.33.166.dist-info/RECORD,,
|
/shancx/{Path.py → path.py}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|