shancx 1.9.33.160__py3-none-any.whl → 1.9.33.162__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
@@ -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
+
14
15
  import logging
15
16
  from logging.handlers import RotatingFileHandler
16
17
  import os
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):
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=False):
19
19
  '''set up logger with rotating file handler'''
20
20
  l = logging.getLogger(logger_name)
21
21
  if handlersflag:
@@ -24,7 +24,9 @@ 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
- crDir(log_file)
27
+ log_dir = os.path.dirname(log_file)
28
+ if not os.path.exists(log_dir):
29
+ os.makedirs(log_dir, exist_ok=True)
28
30
  # Use RotatingFileHandler with 'w' mode to overwrite log file if needed
29
31
  mode = 'w' if overwrite else 'a'
30
32
  fh = RotatingFileHandler(log_file, mode=mode, maxBytes=max_bytes, backupCount=backup_count)
shancx/__init__.py CHANGED
@@ -346,12 +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
- return False
349
+ return True
350
350
  try:
351
351
  os.makedirs(os.path.dirname(lock_file_path), exist_ok=True)
352
352
  with open(lock_file_path, 'w') as f:
353
353
  f.write(f"process_id:{os.getpid()},create_time:{datetime.datetime.now()}")
354
- return True
354
+ return False
355
355
  except Exception as e:
356
356
  print(f"创建锁文件失败 create lock failed : {e}")
357
357
  return False
@@ -364,39 +364,7 @@ if os.path.exists(lock_file):
364
364
  print(f"锁文件存在,已有程序在处理时次 {utc_time_str},跳过")
365
365
  return False
366
366
  """
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
- """
367
+
400
368
  import multiprocessing
401
369
  import sys
402
370
  from typing import Optional, Literal
shancx/wait.py CHANGED
@@ -167,7 +167,8 @@ 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
- return False
170
+ logger.info(f"{lock_file} not exists error A lock file needs to be created. ")
171
+ return False
171
172
  try:
172
173
  with open(lock_file, 'r') as f:
173
174
  content = f.read().strip()
@@ -175,14 +176,12 @@ def check_lock(lock_file):
175
176
  pid_str = content.split('process_id:')[1].split(',')[0]
176
177
  pid = int(pid_str)
177
178
  if not is_process_alive(pid):
178
- print(f"进程 {pid} 已消亡,清理锁文件")
179
179
  os.remove(lock_file)
180
180
  return False
181
181
  else:
182
- print(f"进程 {pid} 仍在运行,跳过执行")
183
182
  return True
184
183
  except Exception as e:
185
- print(f"锁文件解析错误,清理: {e}")
184
+ print(f"lock anaylysis error,clean : {e}")
186
185
  os.remove(lock_file)
187
186
  return False
188
187
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shancx
3
- Version: 1.9.33.160
3
+ Version: 1.9.33.162
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: shancx
@@ -6,7 +6,7 @@ shancx/Point.py,sha256=gyIomOVbNoz6SOcAhhTS26NHBeJ0TOwB-ljNsBWN1ZE,1909
6
6
  shancx/QC.py,sha256=gVH1jAZ2tI-sDygozwfXQgLEJNJscFuzxexWXuXHWHw,2803
7
7
  shancx/Read.py,sha256=xX4ciDoWhL9KAsN3cWvaFAOMlSVwR56AR3dSB-SBnLI,3139
8
8
  shancx/ZR.py,sha256=5APchqVoI1G2MkrN9YJSWCwfLUygcSFIsUXSo9aq1Qg,341
9
- shancx/__init__.py,sha256=ejEaYlajqIeXfIpXzVeAIUfvBlExWhyu5pcc-SVFqW4,19744
9
+ shancx/__init__.py,sha256=_252RPBgKUVUL9VmXR9k-maFQvKVk-yHzD_ROh6b940,18695
10
10
  shancx/args.py,sha256=Nr80vgQpT3m31_crKGf5DvofCxyERJFbqJ1sHb1BIqs,1042
11
11
  shancx/bak.py,sha256=eKe2o1Yq7LCldoA-LXi14s_QNf1BkQsDsWJ7pDoscrw,25428
12
12
  shancx/cmp.py,sha256=cIQv-QTl-22FJa6tmHyBu_IQmMq5LnsQGGFK5jc5hMA,893
@@ -16,7 +16,7 @@ shancx/info.py,sha256=0rk_L8Z5uj9RliaZrzT-CArH9ZObmdmcp-1RxAItL08,1122
16
16
  shancx/netdfJU.py,sha256=96KR9NMLr2Kcs_OOMpX7QPujdWUj0GCEUIZ7_4_pBxw,7741
17
17
  shancx/sendM.py,sha256=CEpeHavseWILlfevhfOMYxYUIWhh4fCNkXGRsEjMxBE,3352
18
18
  shancx/tool.py,sha256=T1Uwsd5vcfKLEMGq7DmhPOmsnBNZgYq-QML8W2a6KTc,1027
19
- shancx/wait.py,sha256=OgT9JmEgMH7d3ir3TEksx0_Kyl_S4bkOKl50jvVpdFA,8575
19
+ shancx/wait.py,sha256=TvVWVfOCP8TF5efug3vy5sJFNkXuW5i52eSebbzFo3U,8520
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=BF6FZIg48DFfQLmfefc1_IFUJRBI8aRyl_2npuykx60,3128
65
+ shancx/NN/__init__.py,sha256=JQgNPBqnvckGDYnBmdQw-nauBS5mN3sba6nf1aFVJik,3204
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.160.dist-info/METADATA,sha256=HDIaLeKeArJA9Yb4uG3HIQtZBuEIAiFAZN2zIoFGcwo,644
87
- shancx-1.9.33.160.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
88
- shancx-1.9.33.160.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
89
- shancx-1.9.33.160.dist-info/RECORD,,
86
+ shancx-1.9.33.162.dist-info/METADATA,sha256=U4oQnxDS0eFASrqeB81ib9-iHsddJLMp_gTtAOUdq9g,644
87
+ shancx-1.9.33.162.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
88
+ shancx-1.9.33.162.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
89
+ shancx-1.9.33.162.dist-info/RECORD,,