shadowshell 0.0.24__tar.gz → 0.0.30__tar.gz

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.
@@ -1,20 +1,18 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.24
4
- Summary: shadowshell.xyz
5
- Author-email: shadowshell <shadowshell@foxmail.com>
3
+ Version: 0.0.30
4
+ Summary: www.shadowshell.xyz
5
+ Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.6
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: requests
12
-
13
-
11
+ Requires-Dist: configparser
14
12
 
15
13
  # Install
16
14
 
17
- ``` BASH
15
+ ``` shell
18
16
 
19
17
  > pip3 install shadowshell --upgrade
20
18
 
@@ -1,8 +1,6 @@
1
-
2
-
3
1
  # Install
4
2
 
5
- ``` BASH
3
+ ``` shell
6
4
 
7
5
  > pip3 install shadowshell --upgrade
8
6
 
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "shadowshell" # 全局唯一名称(检查PyPI是否被占用)
7
- version = "0.0.24" # 版本号(每次更新需递增)
8
- #version = "0.0.25" # 版本号(每次更新需递增)
9
- authors = [{ name = "shadowshell", email = "shadowshell@foxmail.com" }]
10
- description = "shadowshell.xyz"
7
+ #version = "0.0.24" # 版本号(每次更新需递增)
8
+ version = "0.0.30" # 版本号(每次更新需递增)
9
+ authors = [{ name = "shadowshell", email = "shadowshellxyz@foxmail.com" }]
10
+ description = "www.shadowshell.xyz"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.6" # 支持的Python版本
13
13
  license = { text = "MIT" } # 协议类型
@@ -15,7 +15,9 @@ classifiers = [ # 分类标签(可选)
15
15
  "Programming Language :: Python :: 3",
16
16
  "Operating System :: OS Independent",
17
17
  ]
18
- dependencies = ["requests"] # 依赖库(如 ["requests>=2.25"])
18
+ dependencies = [
19
+ "configparser"
20
+ ] # 依赖库(如 ["requests>=2.25"])
19
21
 
20
22
  # 关键配置:指定包路径和自动发现规则
21
23
  [tool.setuptools]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadow shell
6
+ """
7
+
8
+ from shadowshell.logger import Logger
9
+ from shadowshell.logger_factory import LoggerFactory
10
+ from shadowshell.bootstrap import ShadowShell, performance_monitor, hello, shadowshell, invoke_with_tmpl, TestTemplate, testserver, cnnserver
11
+ from shadowshell.git_shell import GitShell
12
+ from shadowshell.configurator import Configurator
13
+
14
+ __all__ = ['ShadowShell', 'performance_monitor', 'hello', 'shadowshell', 'Configurator', 'invoke_with_tmpl', 'TestTemplate', 'Logger', 'LoggerFactory', 'GitShell', 'testserver', 'cnnserver']
@@ -5,15 +5,28 @@ import os
5
5
  # import requests
6
6
  from datetime import datetime
7
7
  from shadowshell.logger_factory import LoggerFactory
8
+ import time
9
+
10
+ logger = LoggerFactory().get_logger()
11
+
12
+ def performance_monitor(func):
13
+ def wrapper(*args, **kwargs):
14
+ start = time.perf_counter()
15
+ result = func(*args, **kwargs)
16
+ elapsed = time.perf_counter() - start
17
+ logger.info(f"[{func.__name__}] has ran, time elapsed:{elapsed:.6f} s.")
18
+ return result
19
+ return wrapper
8
20
 
9
21
  """
10
22
  ShadowShell
11
23
 
12
- @author: shadow shell
24
+ @author: shadowshell
13
25
  """
14
26
  class ShadowShell:
15
27
 
16
28
  def __init__(self):
29
+ self.logger = LoggerFactory().get_logger()
17
30
  pass
18
31
 
19
32
  def hello(self):
@@ -22,43 +35,52 @@ class ShadowShell:
22
35
  formatted_current_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
23
36
  print("Now is " + formatted_current_time)
24
37
 
25
- def test(self):
26
- self.hello()
38
+ def test(self, func, **args):
39
+ try:
40
+ self.logger.debug('-->> Ready')
41
+ func(**args)
42
+ self. logger.debug('-->> Do something')
43
+ except Exception as e:
44
+ self.logger.error(e)
45
+ except:
46
+ self.logger.error(sys.exc_info()[0])
47
+ finally:
48
+ self.logger.debug('-->> Done')
49
+ return
27
50
 
28
51
  # def request(self):
29
52
  # print(requests.get("https://wwww.baidu.com"))
30
53
 
54
+ from shadowshell.logger_factory import LoggerFactory
55
+ import sys
31
56
 
32
57
  class TestTemplate:
33
58
 
34
59
  def __init__(self):
60
+ self.logger = LoggerFactory().get_logger()
35
61
  return
36
62
 
37
63
  def test(self):
38
64
 
39
65
  try:
40
- self.console('-->> Ready')
66
+ self.logger.debug('-->> Ready')
41
67
 
42
68
  self.test0()
43
69
 
44
- self.console('-->> Do something')
70
+ self.logger.debug('-->> Do something')
45
71
 
46
72
  except Exception as e:
47
- self.console(e)
73
+ self.logger.error(e)
48
74
  except:
49
- self.console(sys.exc_info()[0])
75
+ self.logger.error(sys.exc_info()[0])
50
76
  finally:
51
- self.console('-->> Done')
77
+ self.logger.debug('-->> Done')
52
78
  return
53
79
 
54
80
  def test0(self):
55
- self.console('Nothing')
81
+ self.logger.debug('Nothing')
56
82
  return
57
83
 
58
- def console(self, content):
59
- print('[CONSOLE] %s' % (content))
60
-
61
- logger = LoggerFactory().get_logger()
62
84
 
63
85
  def testserver():
64
86
  os.system("ping shadowshell.xyz")
@@ -74,15 +96,17 @@ def shadowshell(**args):
74
96
 
75
97
  def invoke_with_tmpl(func, **args):
76
98
  try:
77
- logger.info('-->> Ready')
99
+ logger.debug('-->> Ready')
100
+
78
101
  func(**args)
79
- logger.info('-->> Do something')
102
+
103
+ logger.debug('-->> Do something')
80
104
  except Exception as e:
81
105
  logger.error(e)
82
106
  except:
83
107
  logger.error(sys.exc_info()[0])
84
108
  finally:
85
- logger.info('-->> Done')
109
+ logger.debug('-->> Done')
86
110
  return
87
111
 
88
112
  if __name__ == "__main__":
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Configurator
6
+ @author: shadow walker
7
+ """
8
+
9
+ import configparser
10
+
11
+ from shadowshell import LoggerFactory
12
+
13
+ class Configurator:
14
+
15
+ config = None;
16
+
17
+ def __init__(self, config_file):
18
+
19
+ self.logger = LoggerFactory().get_logger()
20
+
21
+ # 加载配置文件
22
+ self.config = configparser.ConfigParser()
23
+ self.config.read(config_file)
24
+ self.logger.debug("load and read config file : %s." % (config_file))
25
+
26
+ def get(self, group, key):
27
+ value = self.config.get(group, key)
28
+ self.logger.debug("group -> %s, key -> %s, value -> %s" % (group, key, value))
29
+ return value
30
+
31
+
@@ -1,20 +1,18 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.24
4
- Summary: shadowshell.xyz
5
- Author-email: shadowshell <shadowshell@foxmail.com>
3
+ Version: 0.0.30
4
+ Summary: www.shadowshell.xyz
5
+ Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.6
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: requests
12
-
13
-
11
+ Requires-Dist: configparser
14
12
 
15
13
  # Install
16
14
 
17
- ``` BASH
15
+ ``` shell
18
16
 
19
17
  > pip3 install shadowshell --upgrade
20
18
 
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  src/shadowshell/__init__.py
4
4
  src/shadowshell/bootstrap.py
5
+ src/shadowshell/configurator.py
5
6
  src/shadowshell/console_logger.py
6
7
  src/shadowshell/git_shell.py
7
8
  src/shadowshell/logger.py
@@ -0,0 +1 @@
1
+ configparser
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @author: shadow shell
6
- """
7
-
8
- from shadowshell.logger import Logger
9
- from shadowshell.logger_factory import LoggerFactory
10
- from shadowshell.bootstrap import ShadowShell, hello, shadowshell, invoke_with_tmpl, TestTemplate, testserver, cnnserver
11
- from shadowshell.git_shell import GitShell
12
-
13
- __all__ = ['ShadowShell', 'hello', 'shadowshell', 'invoke_with_tmpl', 'TestTemplate', 'Logger', 'LoggerFactory', 'GitShell', 'testserver', 'cnnserver']
@@ -1 +0,0 @@
1
- requests
File without changes