shadowshell 0.0.37__tar.gz → 0.0.38__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.
- {shadowshell-0.0.37 → shadowshell-0.0.38}/PKG-INFO +1 -1
- {shadowshell-0.0.37 → shadowshell-0.0.38}/pyproject.toml +2 -2
- shadowshell-0.0.38/src/shadowshell/__init__.py +16 -0
- shadowshell-0.0.38/src/shadowshell/boot/__init__.py +10 -0
- shadowshell-0.0.38/src/shadowshell/boot/starter.py +11 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/bootstrap.py +1 -39
- shadowshell-0.0.38/src/shadowshell/config/__init__.py +10 -0
- shadowshell-0.0.38/src/shadowshell/config/configurator.py +31 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/configurator.py +1 -1
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/logger_factory.py +0 -1
- shadowshell-0.0.38/src/shadowshell/logging/__init__.py +12 -0
- shadowshell-0.0.38/src/shadowshell/logging/console_logger.py +27 -0
- shadowshell-0.0.38/src/shadowshell/logging/logger.py +25 -0
- shadowshell-0.0.38/src/shadowshell/logging/logger_factory.py +23 -0
- shadowshell-0.0.38/src/shadowshell/monitor/__init__.py +13 -0
- shadowshell-0.0.38/src/shadowshell/monitor/monitor.py +61 -0
- shadowshell-0.0.38/src/shadowshell/serialize/__init__.py +15 -0
- shadowshell-0.0.38/src/shadowshell/serialize/serializer.py +23 -0
- shadowshell-0.0.38/src/shadowshell/serialize/serializer_factory.py +20 -0
- shadowshell-0.0.38/src/shadowshell/serialize/serializer_json.py +28 -0
- shadowshell-0.0.38/src/shadowshell/test/__init__.py +12 -0
- shadowshell-0.0.38/src/shadowshell/test/test.py +14 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell.egg-info/PKG-INFO +1 -1
- shadowshell-0.0.38/src/shadowshell.egg-info/SOURCES.txt +32 -0
- shadowshell-0.0.37/src/shadowshell/__init__.py +0 -14
- shadowshell-0.0.37/src/shadowshell.egg-info/SOURCES.txt +0 -16
- {shadowshell-0.0.37 → shadowshell-0.0.38}/README.md +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/setup.cfg +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/console_logger.py +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/git_shell.py +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/logger.py +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell/stock_trader.py +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell.egg-info/dependency_links.txt +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell.egg-info/requires.txt +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/src/shadowshell.egg-info/top_level.txt +0 -0
- {shadowshell-0.0.37 → shadowshell-0.0.38}/tests/tests.py +0 -0
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "shadowshell" # 全局唯一名称(检查PyPI是否被占用)
|
|
7
|
-
|
|
8
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.38" # 版本号(每次更新需递增)
|
|
8
|
+
#version = "0.0.61" # 版本号(每次更新需递增)
|
|
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']
|
|
@@ -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,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
|
+
|
|
@@ -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,23 @@
|
|
|
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 = None
|
|
14
|
+
|
|
15
|
+
def __init__(self):
|
|
16
|
+
self.logger = ConsoleLogger()
|
|
17
|
+
|
|
18
|
+
def get_logger(self, name = "default"):
|
|
19
|
+
return self.logger
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
LoggerFactory().get_logger().info("test")
|
|
23
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
try:
|
|
37
|
+
result = func(*args, **kwargs)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
logger.error(e)
|
|
40
|
+
raise
|
|
41
|
+
except:
|
|
42
|
+
logger.error(sys.exc_info()[0])
|
|
43
|
+
raise
|
|
44
|
+
finally:
|
|
45
|
+
elapsed = time.perf_counter() - start
|
|
46
|
+
# log
|
|
47
|
+
if (class_name is not None):
|
|
48
|
+
logger.info(f"[FUNCTION_MONITOR][{class_name}.{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
|
|
49
|
+
else:
|
|
50
|
+
logger.info(f"[FUNCTION_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
|
|
51
|
+
|
|
52
|
+
# callback
|
|
53
|
+
if callback is not None:
|
|
54
|
+
try:
|
|
55
|
+
callback(args, kwargs, result, f"{elapsed:.6f}")
|
|
56
|
+
finally:
|
|
57
|
+
logger.error(sys.exc_info()[0])
|
|
58
|
+
|
|
59
|
+
return result
|
|
60
|
+
return wrapper
|
|
61
|
+
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,32 @@
|
|
|
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/logging/__init__.py
|
|
21
|
+
src/shadowshell/logging/console_logger.py
|
|
22
|
+
src/shadowshell/logging/logger.py
|
|
23
|
+
src/shadowshell/logging/logger_factory.py
|
|
24
|
+
src/shadowshell/monitor/__init__.py
|
|
25
|
+
src/shadowshell/monitor/monitor.py
|
|
26
|
+
src/shadowshell/serialize/__init__.py
|
|
27
|
+
src/shadowshell/serialize/serializer.py
|
|
28
|
+
src/shadowshell/serialize/serializer_factory.py
|
|
29
|
+
src/shadowshell/serialize/serializer_json.py
|
|
30
|
+
src/shadowshell/test/__init__.py
|
|
31
|
+
src/shadowshell/test/test.py
|
|
32
|
+
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|