codosdk 1.0.30__tar.gz → 1.0.31__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.
- {codosdk-1.0.30 → codosdk-1.0.31}/PKG-INFO +1 -1
- {codosdk-1.0.30 → codosdk-1.0.31}/codosdk.egg-info/PKG-INFO +1 -1
- {codosdk-1.0.30 → codosdk-1.0.31}/setup.py +1 -1
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/application.py +4 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/consts.py +9 -0
- codosdk-1.0.31/websdk2/logger.py +99 -0
- codosdk-1.0.30/websdk2/logger.py +0 -42
- {codosdk-1.0.30 → codosdk-1.0.31}/LICENSE +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/README.md +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/codosdk.egg-info/SOURCES.txt +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/codosdk.egg-info/dependency_links.txt +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/codosdk.egg-info/requires.txt +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/codosdk.egg-info/top_level.txt +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/opssdk/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/opssdk/utils/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/pyproject.toml +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/setup.cfg +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/api_set.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/admin_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/agent_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/cmdb_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/kerrigan_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/mgv4_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/notice_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/apis/task_apis.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/base_handler.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cache.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cache_context.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/client.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cloud/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cloud/qcloud_api.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cloud/ucloud_api.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/cloud_utils.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/configs.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/crud_utils.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/db_context.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/error.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/fetch_coroutine.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/jwt_token.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/ldap.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/model_utils.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/mqhelper.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/program.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/salt_api.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/sqlalchemy_pagination.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/tools.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/utils/__init__.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/utils/cc_crypto.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/utils/date_format.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/utils/pydantic_utils.py +0 -0
- {codosdk-1.0.30 → codosdk-1.0.31}/websdk2/web_logs.py +0 -0
|
@@ -9,7 +9,7 @@ desc : CODO SDK
|
|
|
9
9
|
import sys
|
|
10
10
|
from setuptools import setup, find_packages
|
|
11
11
|
|
|
12
|
-
VERSION = '1.0.
|
|
12
|
+
VERSION = '1.0.31'
|
|
13
13
|
|
|
14
14
|
if sys.version_info < (2, 7) or (3, 0) <= sys.version_info < (3, 6):
|
|
15
15
|
print('This program requires at least Python 2.7 or 3.6 to run.')
|
|
@@ -15,6 +15,7 @@ from tornado.options import options, define
|
|
|
15
15
|
from tornado.web import Application as tornadoApp
|
|
16
16
|
from tornado.web import RequestHandler
|
|
17
17
|
from .configs import configs
|
|
18
|
+
from .consts import const
|
|
18
19
|
from .logger import init_logging
|
|
19
20
|
|
|
20
21
|
# options.log_file_prefix = "/tmp/codo.log"
|
|
@@ -41,6 +42,9 @@ class Application(tornadoApp):
|
|
|
41
42
|
max_buffer_size = configs.get('max_buffer_size')
|
|
42
43
|
max_body_size = configs.get('max_body_size')
|
|
43
44
|
super(Application, self).__init__(handlers, default_host, transforms, **configs)
|
|
45
|
+
if configs.get(const.LOG_LEVEL) in [10, 20, 30, 40]:
|
|
46
|
+
logging.getLogger().setLevel(configs.get(const.LOG_LEVEL))
|
|
47
|
+
|
|
44
48
|
http_server = httpserver.HTTPServer(self, max_buffer_size=max_buffer_size, max_body_size=max_body_size)
|
|
45
49
|
http_server.listen(options.port, address=options.addr)
|
|
46
50
|
self.io_loop = ioloop.IOLoop.instance()
|
|
@@ -94,6 +94,15 @@ const.MQ_PWD = 'MQ_PWD'
|
|
|
94
94
|
const.DEFAULT_MQ_KEY = 'default'
|
|
95
95
|
const.AGENT_MQ_KEY = 'agent'
|
|
96
96
|
|
|
97
|
+
# CRITICAL = 50
|
|
98
|
+
# FATAL = CRITICAL
|
|
99
|
+
# ERROR = 40
|
|
100
|
+
# WARNING = 30
|
|
101
|
+
# WARN = WARNING
|
|
102
|
+
# INFO = 20
|
|
103
|
+
# DEBUG = 10
|
|
104
|
+
# NOTSET = 0
|
|
105
|
+
const.LOG_LEVEL = "log_level"
|
|
97
106
|
# JMS
|
|
98
107
|
const.JMS_CONFIG_ITEM = 'jmss'
|
|
99
108
|
const.DEFAULT_JMS_KEY = 'default'
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8-*-
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
import sys
|
|
6
|
+
import datetime
|
|
7
|
+
import tornado.log
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# options.log_file_prefix = os.path.join(os.path.dirname(os.path.dirname(__file__)), f'/tmp/codo.log')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# class LogFormatter(tornado.log.LogFormatter):
|
|
14
|
+
# default_msec_format = '%s.%03d'
|
|
15
|
+
#
|
|
16
|
+
# def __init__(self):
|
|
17
|
+
# super(LogFormatter, self).__init__(
|
|
18
|
+
# fmt='%(color)s%(asctime)s | %(levelname)s%(end_color)s | %(filename)s:%(funcName)s:%(lineno)s - %(message)s',
|
|
19
|
+
# datefmt='%Y-%m-%d %H:%M:%S.%f'
|
|
20
|
+
# )
|
|
21
|
+
#
|
|
22
|
+
# def formatTime(self, record, datefmt=None):
|
|
23
|
+
# ct = datetime.datetime.now()
|
|
24
|
+
# t = ct.strftime(self.default_time_format)
|
|
25
|
+
# s = self.default_msec_format % (t, record.msecs)
|
|
26
|
+
# return s
|
|
27
|
+
#
|
|
28
|
+
#
|
|
29
|
+
# def init_logging():
|
|
30
|
+
# # write file
|
|
31
|
+
# [
|
|
32
|
+
# i.setFormatter(LogFormatter())
|
|
33
|
+
# for i in logging.getLogger().handlers
|
|
34
|
+
# ]
|
|
35
|
+
# logging.getLogger().setLevel(logging.INFO)
|
|
36
|
+
# # write stdout
|
|
37
|
+
# stdout_handler = logging.StreamHandler(sys.stdout)
|
|
38
|
+
# stdout_handler.setFormatter(LogFormatter())
|
|
39
|
+
# logging.getLogger().addHandler(stdout_handler)
|
|
40
|
+
# logging.info('[APP Logging Init] logging has been started')
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class LogFormatter(tornado.log.LogFormatter):
|
|
44
|
+
"""
|
|
45
|
+
Custom log formatter to add color and detailed information to logs.
|
|
46
|
+
"""
|
|
47
|
+
default_msec_format = '%s.%03d'
|
|
48
|
+
|
|
49
|
+
def __init__(self):
|
|
50
|
+
super(LogFormatter, self).__init__(
|
|
51
|
+
fmt='%(color)s%(asctime)s | %(levelname)s%(end_color)s | '
|
|
52
|
+
'%(filename)s:%(funcName)s:%(lineno)d - %(message)s',
|
|
53
|
+
datefmt='%Y-%m-%d %H:%M:%S.%f'
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def formatTime(self, record, datefmt=None):
|
|
57
|
+
"""
|
|
58
|
+
Customize the timestamp format to include milliseconds.
|
|
59
|
+
"""
|
|
60
|
+
ct = datetime.datetime.fromtimestamp(record.created)
|
|
61
|
+
t = ct.strftime(self.default_time_format)
|
|
62
|
+
s = self.default_msec_format % (t, record.msecs)
|
|
63
|
+
return s
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def init_logging(log_level=logging.INFO):
|
|
67
|
+
"""
|
|
68
|
+
Initialize the logging system with custom formatter and handlers.
|
|
69
|
+
|
|
70
|
+
:param log_level: Logging level, e.g., logging.DEBUG, logging.INFO, etc.
|
|
71
|
+
"""
|
|
72
|
+
# Apply the custom formatter to existing handlers
|
|
73
|
+
for handler in logging.getLogger().handlers:
|
|
74
|
+
handler.setFormatter(LogFormatter())
|
|
75
|
+
|
|
76
|
+
# Set the log level
|
|
77
|
+
logging.getLogger().setLevel(log_level)
|
|
78
|
+
|
|
79
|
+
# Add a handler for stdout logging
|
|
80
|
+
stdout_handler = logging.StreamHandler(sys.stdout)
|
|
81
|
+
stdout_handler.setFormatter(LogFormatter())
|
|
82
|
+
logging.getLogger().addHandler(stdout_handler)
|
|
83
|
+
|
|
84
|
+
logging.info(f'[APP Logging Init] Logging initialized with level: {logging.getLevelName(log_level)}')
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# Example usage
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
# Pass the desired log level as a parameter
|
|
90
|
+
# log_level = logging.DEBUG # You can adjust this to logging.INFO, logging.WARNING, etc.
|
|
91
|
+
# init_logging(log_level)
|
|
92
|
+
#
|
|
93
|
+
# # Test logging at different levels
|
|
94
|
+
# logging.debug("This is a debug message")
|
|
95
|
+
# logging.info("This is an info message")
|
|
96
|
+
# logging.warning("This is a warning message")
|
|
97
|
+
# logging.error("This is an error message")
|
|
98
|
+
# logging.critical("This is a critical message")
|
|
99
|
+
pass
|
codosdk-1.0.30/websdk2/logger.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*-coding:utf-8-*-
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import logging
|
|
6
|
-
import sys
|
|
7
|
-
import datetime
|
|
8
|
-
import tornado.log
|
|
9
|
-
|
|
10
|
-
# from tornado.options import options
|
|
11
|
-
#
|
|
12
|
-
# options.log_file_prefix = os.path.join(os.path.dirname(os.path.dirname(__file__)), f'/tmp/codo.log')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class LogFormatter(tornado.log.LogFormatter):
|
|
16
|
-
default_msec_format = '%s.%03d'
|
|
17
|
-
|
|
18
|
-
def __init__(self):
|
|
19
|
-
super(LogFormatter, self).__init__(
|
|
20
|
-
fmt='%(color)s%(asctime)s | %(levelname)s%(end_color)s | %(filename)s:%(funcName)s:%(lineno)s - %(message)s',
|
|
21
|
-
datefmt='%Y-%m-%d %H:%M:%S.%f'
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
def formatTime(self, record, datefmt=None):
|
|
25
|
-
ct = datetime.datetime.now()
|
|
26
|
-
t = ct.strftime(self.default_time_format)
|
|
27
|
-
s = self.default_msec_format % (t, record.msecs)
|
|
28
|
-
return s
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def init_logging():
|
|
32
|
-
# write file
|
|
33
|
-
[
|
|
34
|
-
i.setFormatter(LogFormatter())
|
|
35
|
-
for i in logging.getLogger().handlers
|
|
36
|
-
]
|
|
37
|
-
logging.getLogger().setLevel(logging.INFO)
|
|
38
|
-
# write stdout
|
|
39
|
-
stdout_handler = logging.StreamHandler(sys.stdout)
|
|
40
|
-
stdout_handler.setFormatter(LogFormatter())
|
|
41
|
-
logging.getLogger().addHandler(stdout_handler)
|
|
42
|
-
logging.info('[APP Logging Init] logging has been started')
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|