-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
64 lines (55 loc) · 1.72 KB
/
utils.py
File metadata and controls
64 lines (55 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
#coding=utf-8
"""
File: utils.py
Description: the utils function library
Author: 0x7F@knownsec404
Time: 2021.06.30
"""
import logging
import time
import config
#**********************************************************************
# @Function: logger_init()
# @Description: the global log object initialize function
# @Parameter: None
# @Return: None
#**********************************************************************
def logger_init():
logger = logging.getLogger("emailbot")
logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(config.LOG_LEVEL)
formatter = logging.Formatter(config.LOG_FORMAT)
sh.setFormatter(formatter)
logger.addHandler(sh)
return logger
# end logger_init()
logger = logger_init()
#**********************************************************************
# @Function: get_format_date()
# @Description: get current time and format
# @Parameter: None
# @Return: str, the be formatted date string
#**********************************************************************
def get_format_date():
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# end get_date()
#**********************************************************************
# @Function: get_format_date()
# @Description: get current time and format
# @Parameter: None
# @Return: str, the be formatted date string
#**********************************************************************
def parse_args_server(serv):
array = serv.split(":")
if len(array) == 1:
# return server address and default port 0
return array[0], 0
port = array[1]
if port.isdigit():
port = int(port)
else:
port = 0
return array[0], port
# end parse_args_server()