shancx 1.9.33.171__py3-none-any.whl → 1.9.33.174__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 CHANGED
@@ -4,13 +4,9 @@ import os
4
4
  def start():
5
5
  print("import successful")
6
6
  # constants
7
- __author__ = 'shancx'
8
-
9
- __author_email__ = 'shancx@126.com'
10
-
11
- # @Time : 2023/09/27 下午8:52
12
- # @Author : shanchangxi
13
- # @File : util_log.py
7
+ __author__ = 'shancx'
8
+ __author_email__ = 'shanhe12@163.com'
9
+ __time__ = '20251028 21:16'
14
10
  import logging
15
11
  from logging.handlers import RotatingFileHandler
16
12
  import os
@@ -37,7 +33,6 @@ def _loggers(logger_name="loggers", root="./logs", phase="project", level=loggin
37
33
  l.addHandler(sh)
38
34
  return l
39
35
 
40
-
41
36
  """
42
37
  logger = _loggers(logger_name="test_logger", root=curpathplus, phase="test_log", overwrite=True, screen=True)
43
38
  # 测试日志输出
@@ -64,6 +59,53 @@ if __name__ == "__main__":
64
59
  logger.info("这是一条INFO日志")
65
60
  '''
66
61
 
62
+ import os
63
+ import glob
64
+ import logging
65
+ from datetime import datetime
66
+ from shancx import loggers as logger
67
+ def cleanupLogs(log_dir='/mnt/wtx_weather_forecast/scx/SATH9SEAStest/logs', keep_count=10,
68
+ pattern='*.log', recursive=False, dry_run=False):
69
+ stats = {'total_dirs': 0, 'deleted_files': 0, 'errors': []}
70
+ def _cleanup_dir(directory):
71
+ stats['total_dirs'] += 1
72
+ if not os.path.exists(directory):
73
+ logging.warning(f"目录不存在: {directory}")
74
+ return
75
+ file_paths = glob.glob(os.path.join(directory, pattern))
76
+ log_files = [(path, os.path.getmtime(path)) for path in file_paths]
77
+ log_files.sort(key=lambda x: x[1], reverse=True)
78
+ if len(log_files) <= keep_count:
79
+ logging.info(f"目录 {directory} 中的文件数量 ({len(log_files)}) 不超过保留数量 ({keep_count}),无需清理")
80
+ return
81
+ files_to_delete = log_files[keep_count:]
82
+ for file_path, mtime in files_to_delete:
83
+ try:
84
+ if dry_run:
85
+ logging.info(f"[试运行] 将删除: {file_path} (修改时间: {datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S')})")
86
+ else:
87
+ os.remove(file_path)
88
+ logging.info(f"已删除: {file_path} (修改时间: {datetime.fromtimestamp(mtime).strftime('%Y-%m-%d %H:%M:%S')})")
89
+ stats['deleted_files'] += 1
90
+ except Exception as e:
91
+ error_msg = f"删除失败 {file_path}: {str(e)}"
92
+ logging.error(error_msg)
93
+ stats['errors'].append(error_msg)
94
+ if recursive:
95
+ for root, _, _ in os.walk(log_dir):
96
+ _cleanup_dir(root)
97
+ else:
98
+ _cleanup_dir(log_dir)
99
+ return stats
100
+ """
101
+ if __name__ == "__main__":
102
+ dir = "/mnt/wtx_weather_forecast/scx/SATH9SEAStest/logs/H9SEAS/"
103
+ stats = cleanupLogs(dir,3, '*.log', False, False)
104
+ logging.info(f"清理完成: 处理目录数={stats['total_dirs']}, 删除文件数={stats['deleted_files']}, 错误数={len(stats['errors'])}")
105
+ if stats['errors']:
106
+ logging.error(f"错误详情: {stats['errors']}")
107
+ """
108
+
67
109
  from itertools import product
68
110
  from concurrent.futures import ProcessPoolExecutor as PoolExecutor, as_completed
69
111
  import sys
@@ -90,6 +132,27 @@ def Mul_sub(task, param_list, num=6):
90
132
  sys.exit(1)
91
133
  print("All tasks completed")
92
134
 
135
+ from concurrent.futures import ThreadPoolExecutor
136
+ from itertools import product
137
+ def Mul_TH(task, param_list, max_workers=6):
138
+ print(f"Thread num: {max_workers}")
139
+ validate_param_list(param_list)
140
+ task_args = [
141
+ (arg,) if len(param_list) == 1 else arg
142
+ for arg in (
143
+ param_list[0] if len(param_list) == 1
144
+ else product(*param_list)
145
+ )
146
+ ]
147
+ with ThreadPoolExecutor(max_workers) as ex:
148
+ try:
149
+ list(ex.map(task, task_args))
150
+ except KeyboardInterrupt:
151
+ print("\n用户中断操作")
152
+ ex.shutdown(wait=False)
153
+ sys.exit(1)
154
+
155
+
93
156
  # import os
94
157
  # from datetime import datetime
95
158
  # from shancx.NN import _loggers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shancx
3
- Version: 1.9.33.171
3
+ Version: 1.9.33.174
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: shancx
@@ -56,9 +56,13 @@ shancx/Fillmiss/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  shancx/Fillmiss/imgidwJU.py,sha256=CyP4ZlhPpXPqGVzzcLR7lohVl8bWjEceJLo7yvKgtEM,1708
57
57
  shancx/Fillmiss/imgidwLatLonJU.py,sha256=ltYZj9CwN8cVs4Kow64oVN1EiBERgW9FceTUBFkCOAs,4314
58
58
  shancx/Gpu/__init__.py,sha256=4Ahq04phTGVlFWN9Vih0WAh-IqFrhtwM5hj4G1IU2Dk,1950
59
+ shancx/H9/__init__.py,sha256=FCarcXfU2tVD2KrCGKNNUuL51zAWZYHV7lrP7gntvaI,4911
60
+ shancx/H9/ahi_read_hsd.py,sha256=bt9oOOARcXijmyGpmHYXj0NKnuTntZjqx0_tu6Vp2vs,33522
61
+ shancx/H9/ahisearchtable.py,sha256=e2kpz-P5npgL4gzNxn8igERJuWWIysvTNLkptr5_Zcc,9579
62
+ shancx/H9/geometry.py,sha256=ZoCfgP07ANqDxyLf8uFN016DPl7QqW9pAV3sr2ekCng,95893
59
63
  shancx/Hug/__init__.py,sha256=NvcqXM0CSwXYtTr5yj4zfkag_7PZcI5tCsIHjuLNXTQ,3040
60
64
  shancx/Mos/__init__.py,sha256=IDlCLNN6a_mguYmRcAPcevHSDaud5ZhvYNSuASqztcE,1563
61
- shancx/NN/__init__.py,sha256=fVSAQnfE_34zBNw5gz_K5jenY5iE30yoB0eEleMCYqI,4235
65
+ shancx/NN/__init__.py,sha256=uN2Dkqm-rRnp8TDitwMm1PcYYH9KsaQXcraFVuIRf98,7027
62
66
  shancx/Plot/GlobMap.py,sha256=WRvZOf5bo8IfECk1-sN4g6K0CrcJhSoEJAiLvZAWDwg,13021
63
67
  shancx/Plot/Gray2RGB.py,sha256=yDXu1xWVi7OtrS8_ExxK_ev1988kj1ZxoNCWf-kl4Zc,2734
64
68
  shancx/Plot/__init__.py,sha256=R4pywzeVDqEWGMkWeGBAVmopgPBThiLv2RBDlGquNGc,31891
@@ -79,7 +83,7 @@ shancx/Train/multiGpu.py,sha256=D_oZeiSc7VWktpnVDwrFOC1CYZSt9rxOKY5lngE5vFg,820
79
83
  shancx/Train/prepare.py,sha256=vL_8UOA66oZCBIwCICtihsGibivtNgaVJGulJxfNdn8,6793
80
84
  shancx/Train/renet50.py,sha256=wEhYk1X96WE5zuqHqVxWLJa-A5jDNkz4z6edORNufnA,6428
81
85
  shancx/tensBoard/__init__.py,sha256=ga2C5YyJITvvQA1ocpxna_KNFnNRJVwkTjLoIglLZUQ,993
82
- shancx-1.9.33.171.dist-info/METADATA,sha256=_l_QlL7aOUxagFQpVMYER4Misz3TxtUv_T9Ah8QRXTo,644
83
- shancx-1.9.33.171.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
84
- shancx-1.9.33.171.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
85
- shancx-1.9.33.171.dist-info/RECORD,,
86
+ shancx-1.9.33.174.dist-info/METADATA,sha256=Yr3IRyjoqztZUku4KsVKubHkG-88GXh4FwUxl4QFOb8,644
87
+ shancx-1.9.33.174.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
88
+ shancx-1.9.33.174.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
89
+ shancx-1.9.33.174.dist-info/RECORD,,