shadowshell 0.0.37__tar.gz → 0.0.39__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.
Files changed (38) hide show
  1. {shadowshell-0.0.37 → shadowshell-0.0.39}/PKG-INFO +1 -1
  2. {shadowshell-0.0.37 → shadowshell-0.0.39}/pyproject.toml +2 -2
  3. shadowshell-0.0.39/src/shadowshell/__init__.py +16 -0
  4. shadowshell-0.0.39/src/shadowshell/boot/__init__.py +10 -0
  5. shadowshell-0.0.39/src/shadowshell/boot/starter.py +11 -0
  6. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/bootstrap.py +1 -39
  7. shadowshell-0.0.39/src/shadowshell/config/__init__.py +10 -0
  8. shadowshell-0.0.39/src/shadowshell/config/configurator.py +31 -0
  9. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/configurator.py +1 -1
  10. shadowshell-0.0.39/src/shadowshell/file/__init__.py +10 -0
  11. shadowshell-0.0.39/src/shadowshell/file/file_util.py +19 -0
  12. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/logger_factory.py +0 -1
  13. shadowshell-0.0.39/src/shadowshell/logging/__init__.py +12 -0
  14. shadowshell-0.0.39/src/shadowshell/logging/console_logger.py +27 -0
  15. shadowshell-0.0.39/src/shadowshell/logging/logger.py +25 -0
  16. shadowshell-0.0.39/src/shadowshell/logging/logger_factory.py +24 -0
  17. shadowshell-0.0.39/src/shadowshell/monitor/__init__.py +13 -0
  18. shadowshell-0.0.39/src/shadowshell/monitor/monitor.py +64 -0
  19. shadowshell-0.0.39/src/shadowshell/serialize/__init__.py +15 -0
  20. shadowshell-0.0.39/src/shadowshell/serialize/serializer.py +23 -0
  21. shadowshell-0.0.39/src/shadowshell/serialize/serializer_factory.py +20 -0
  22. shadowshell-0.0.39/src/shadowshell/serialize/serializer_json.py +28 -0
  23. shadowshell-0.0.39/src/shadowshell/test/__init__.py +12 -0
  24. shadowshell-0.0.39/src/shadowshell/test/test.py +14 -0
  25. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell.egg-info/PKG-INFO +1 -1
  26. shadowshell-0.0.39/src/shadowshell.egg-info/SOURCES.txt +34 -0
  27. shadowshell-0.0.37/src/shadowshell/__init__.py +0 -14
  28. shadowshell-0.0.37/src/shadowshell.egg-info/SOURCES.txt +0 -16
  29. {shadowshell-0.0.37 → shadowshell-0.0.39}/README.md +0 -0
  30. {shadowshell-0.0.37 → shadowshell-0.0.39}/setup.cfg +0 -0
  31. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/console_logger.py +0 -0
  32. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/git_shell.py +0 -0
  33. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/logger.py +0 -0
  34. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell/stock_trader.py +0 -0
  35. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell.egg-info/dependency_links.txt +0 -0
  36. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell.egg-info/requires.txt +0 -0
  37. {shadowshell-0.0.37 → shadowshell-0.0.39}/src/shadowshell.egg-info/top_level.txt +0 -0
  38. {shadowshell-0.0.37 → shadowshell-0.0.39}/tests/tests.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.37
3
+ Version: 0.0.39
4
4
  Summary: www.shadowshell.xyz
5
5
  Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "shadowshell" # 全局唯一名称(检查PyPI是否被占用)
7
- #version = "0.0.24" # 版本号(每次更新需递增)
8
- version = "0.0.37" # 版本号(每次更新需递增)
7
+ version = "0.0.39" # 版本号(每次更新需递增)
8
+ #version = "0.0.65" # 版本号(每次更新需递增)
9
9
  authors = [{ name = "shadowshell", email = "shadowshellxyz@foxmail.com" }]
10
10
  description = "www.shadowshell.xyz"
11
11
  readme = "README.md"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
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
+ from shadowshell.configurator import Configurator
13
+
14
+ __all__ = [
15
+ 'ShadowShell',
16
+ 'hello', 'shadowshell', 'Configurator', 'invoke_with_tmpl', 'TestTemplate', 'Logger', 'LoggerFactory', 'GitShell', 'testserver', 'cnnserver']
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ from shadowshell.boot.starter import Starter
9
+
10
+ __all__ = ['Starter']
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ class Starter:
9
+
10
+ def __init__(self):
11
+ pass
@@ -71,45 +71,7 @@ class TestTemplate:
71
71
  def test0(self):
72
72
  self.logger.debug('Nothing')
73
73
  return
74
-
75
- def performance_monitor(class_name=None):
76
- def decorator(func):
77
- def wrapper(*args, **kwargs):
78
- start = time.perf_counter()
79
- result = None
80
- try:
81
- result = func(*args, **kwargs)
82
- finally:
83
- elapsed = time.perf_counter() - start
84
- if (class_name is not None):
85
- logger.info(f"[PERFORMANCE_MONITOR][{class_name}.{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
86
- else:
87
- logger.info(f"[PERFORMANCE_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
88
- return result
89
- return wrapper
90
- return decorator
91
-
92
- def function_monitor(class_name=None):
93
- def decorator(func):
94
- def wrapper(*args, **kwargs):
95
- start = time.perf_counter()
96
- result = None
97
- try:
98
- result = func(*args, **kwargs)
99
- except Exception as e:
100
- logger.error(e)
101
- except:
102
- logger.error(sys.exc_info()[0])
103
- finally:
104
- elapsed = time.perf_counter() - start
105
- if (class_name is not None):
106
- logger.info(f"[FUNCTION_MONITOR][{class_name}.{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
107
- else:
108
- logger.info(f"[FUNCTION_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
109
- return result
110
- return wrapper
111
- return decorator
112
-
74
+
113
75
  def testserver():
114
76
  os.system("ping shadowshell.xyz")
115
77
 
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ from shadowshell.config.configurator import Configurator
9
+
10
+ __all__ = ['Configurator']
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Configurator
6
+ @author: shadowshell
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
+
@@ -3,7 +3,7 @@
3
3
 
4
4
  """
5
5
  Configurator
6
- @author: shadow walker
6
+ @author: shadowshell
7
7
  """
8
8
 
9
9
  import configparser
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ from shadowshell.file.file_util import FileUtil
9
+
10
+ __all__ = ['FileUtil']
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ from shadowshell.logging import LoggerFactory
9
+
10
+ class FileUtil:
11
+
12
+ __logger = LoggerFactory.get_logger()
13
+
14
+ @staticmethod
15
+ def get_all(file_path, mode="r", encoding="utf-8"):
16
+ with open(file_path, mode, encoding = encoding) as f:
17
+ content = f.read()
18
+ FileUtil.__logger.debug(f"[{file_path}][All content]{content}")
19
+ return content
@@ -3,7 +3,6 @@
3
3
 
4
4
  """
5
5
  LoggerFactory
6
-
7
6
  @author: shadow shell
8
7
  """
9
8
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ from shadowshell.logging.logger import Logger
9
+ from shadowshell.logging.logger_factory import LoggerFactory
10
+ from shadowshell.logging.console_logger import ConsoleLogger
11
+
12
+ __all__ = ['Logger', 'LoggerFactory', 'ConsoleLogger']
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ ConsoleLogger
6
+
7
+ author: shadow shell
8
+ """
9
+
10
+ from shadowshell.logging.logger import Logger
11
+
12
+ class ConsoleLogger(Logger):
13
+
14
+ def debug(self, content):
15
+ self.__log(content)
16
+
17
+ def info(self, content):
18
+ self.__log(content)
19
+
20
+ def warn(self, content):
21
+ self.__log(content)
22
+
23
+ def error(self, content):
24
+ self.__log(content)
25
+
26
+ def __log(self, content):
27
+ print("%s" % (content))
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Logger
6
+
7
+ @author: shadowshell
8
+ """
9
+
10
+ class Logger:
11
+
12
+ def debug(self, content):
13
+ self.__log(content)
14
+
15
+ def info(self, content):
16
+ self.__log(content)
17
+
18
+ def warn(self, content):
19
+ self.__log(content)
20
+
21
+ def error(self, content):
22
+ self.__log(content)
23
+
24
+ def __log(self, content):
25
+ print("[LOGGER]%s" % content)
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ LoggerFactory
6
+ @author: shadow shell
7
+ """
8
+
9
+ from shadowshell.logging.console_logger import ConsoleLogger
10
+
11
+ class LoggerFactory:
12
+
13
+ __logger = ConsoleLogger()
14
+
15
+ def __init__(self):
16
+ pass
17
+
18
+ @staticmethod
19
+ def get_logger(name = "default"):
20
+ return LoggerFactory.__logger
21
+
22
+ if __name__ == "__main__":
23
+ LoggerFactory().get_logger().info("test")
24
+
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadow shell
6
+ """
7
+
8
+ from shadowshell.monitor.monitor import function_monitor, performance_monitor
9
+
10
+ __all__ = [
11
+ 'function_monitor',
12
+ 'performance_monitor'
13
+ ]
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadowshell
6
+ """
7
+
8
+ import sys
9
+ import time
10
+ from shadowshell.logging import LoggerFactory
11
+
12
+ logger = LoggerFactory().get_logger()
13
+
14
+ def performance_monitor(class_name=None):
15
+ def decorator(func):
16
+ def wrapper(*args, **kwargs):
17
+ start = time.perf_counter()
18
+ result = None
19
+ try:
20
+ result = func(*args, **kwargs)
21
+ finally:
22
+ elapsed = time.perf_counter() - start
23
+ if (class_name is not None):
24
+ logger.info(f"[PERFORMANCE_MONITOR][{class_name}.{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
25
+ else:
26
+ logger.info(f"[PERFORMANCE_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
27
+ return result
28
+ return wrapper
29
+ return decorator
30
+
31
+ def function_monitor(class_name=None, callback=None):
32
+ def decorator(func):
33
+ def wrapper(*args, **kwargs):
34
+ start = time.perf_counter()
35
+ result = None
36
+ is_success = True
37
+ try:
38
+ result = func(*args, **kwargs)
39
+ except Exception as e:
40
+ logger.error(e)
41
+ is_success = False
42
+ raise
43
+ except:
44
+ logger.error(sys.exc_info()[0])
45
+ is_success = False
46
+ raise
47
+ finally:
48
+ elapsed = time.perf_counter() - start
49
+ # log
50
+ if (class_name is not None):
51
+ logger.info(f"[FUNCTION_MONITOR][{class_name}.{func.__name__}] has ran, is_success={is_success}, time elapsed:{elapsed:.6f}s.")
52
+ else:
53
+ logger.info(f"[FUNCTION_MONITOR][{func.__name__}] has ran, is_success={is_success}, time elapsed:{elapsed:.6f}s.")
54
+
55
+ # callback
56
+ if callback is not None:
57
+ try:
58
+ callback(args, kwargs, result, f"{elapsed:.6f}")
59
+ finally:
60
+ logger.error(sys.exc_info()[0])
61
+
62
+ return result
63
+ return wrapper
64
+ return decorator
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadow shell
6
+ """
7
+
8
+ from shadowshell.serialize.serializer import Serializer
9
+ from shadowshell.serialize.serializer_factory import SerializerFactory
10
+
11
+
12
+ __all__ = [
13
+ 'Serializer',
14
+ 'SerializerFactory'
15
+ ]
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Serializer
6
+
7
+ @author: shadowshell
8
+ """
9
+
10
+ from shadowshell.logging import LoggerFactory
11
+
12
+ class Serializer:
13
+
14
+ def __init__(self):
15
+ self.logger = LoggerFactory().get_logger()
16
+
17
+ def serialize(self, object):
18
+ self.logger.warn("No serialize")
19
+ return None
20
+
21
+ def deserialize(self, content):
22
+ self.logger.warn("No deserialize")
23
+ return None
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ SerializerFactory
6
+
7
+ @author: shadowshell
8
+ """
9
+
10
+ from shadowshell.serialize.serializer_json import SerializerJson
11
+
12
+ class SerializerFactory():
13
+
14
+ def __init__(self):
15
+ pass
16
+
17
+ @staticmethod
18
+ def get_instance():
19
+ return SerializerJson()
20
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Serializer
6
+
7
+ @author: shadowshell
8
+ """
9
+
10
+ import json
11
+ from shadowshell.logging import LoggerFactory
12
+ from shadowshell.serialize.serializer import Serializer
13
+
14
+ class SerializerJson(Serializer):
15
+
16
+ def __init__(self):
17
+ self.logger = LoggerFactory().get_logger()
18
+ pass
19
+
20
+ def serialize(self, object):
21
+ json_str = json.dumps(object)
22
+ self.logger.debug(f"Serialized json string: {json_str}.")
23
+ return json_str
24
+
25
+ def deserialize(self, content):
26
+ object=json.loads(content)
27
+ return object
28
+
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @author: shadow shell
6
+ """
7
+
8
+ from shadowshell.test.test import Test
9
+
10
+ __all__ = [
11
+ 'Test'
12
+ ]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ LoggerFactory
6
+ @author: shadowshell
7
+ """
8
+
9
+ from shadowshell.logging import LoggerFactory
10
+
11
+ class Test():
12
+
13
+ def test(self):
14
+ LoggerFactory().get_logger().info("jhaohao")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.37
3
+ Version: 0.0.39
4
4
  Summary: www.shadowshell.xyz
5
5
  Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
@@ -0,0 +1,34 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/shadowshell/__init__.py
4
+ src/shadowshell/bootstrap.py
5
+ src/shadowshell/configurator.py
6
+ src/shadowshell/console_logger.py
7
+ src/shadowshell/git_shell.py
8
+ src/shadowshell/logger.py
9
+ src/shadowshell/logger_factory.py
10
+ src/shadowshell/stock_trader.py
11
+ src/shadowshell.egg-info/PKG-INFO
12
+ src/shadowshell.egg-info/SOURCES.txt
13
+ src/shadowshell.egg-info/dependency_links.txt
14
+ src/shadowshell.egg-info/requires.txt
15
+ src/shadowshell.egg-info/top_level.txt
16
+ src/shadowshell/boot/__init__.py
17
+ src/shadowshell/boot/starter.py
18
+ src/shadowshell/config/__init__.py
19
+ src/shadowshell/config/configurator.py
20
+ src/shadowshell/file/__init__.py
21
+ src/shadowshell/file/file_util.py
22
+ src/shadowshell/logging/__init__.py
23
+ src/shadowshell/logging/console_logger.py
24
+ src/shadowshell/logging/logger.py
25
+ src/shadowshell/logging/logger_factory.py
26
+ src/shadowshell/monitor/__init__.py
27
+ src/shadowshell/monitor/monitor.py
28
+ src/shadowshell/serialize/__init__.py
29
+ src/shadowshell/serialize/serializer.py
30
+ src/shadowshell/serialize/serializer_factory.py
31
+ src/shadowshell/serialize/serializer_json.py
32
+ src/shadowshell/test/__init__.py
33
+ src/shadowshell/test/test.py
34
+ tests/tests.py
@@ -1,14 +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, performance_monitor, function_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', 'function_monitor', 'hello', 'shadowshell', 'Configurator', 'invoke_with_tmpl', 'TestTemplate', 'Logger', 'LoggerFactory', 'GitShell', 'testserver', 'cnnserver']
@@ -1,16 +0,0 @@
1
- README.md
2
- pyproject.toml
3
- src/shadowshell/__init__.py
4
- src/shadowshell/bootstrap.py
5
- src/shadowshell/configurator.py
6
- src/shadowshell/console_logger.py
7
- src/shadowshell/git_shell.py
8
- src/shadowshell/logger.py
9
- src/shadowshell/logger_factory.py
10
- src/shadowshell/stock_trader.py
11
- src/shadowshell.egg-info/PKG-INFO
12
- src/shadowshell.egg-info/SOURCES.txt
13
- src/shadowshell.egg-info/dependency_links.txt
14
- src/shadowshell.egg-info/requires.txt
15
- src/shadowshell.egg-info/top_level.txt
16
- tests/tests.py
File without changes
File without changes