LogFly 2.4__tar.gz → 2.5__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,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 2.4
3
+ Version: 2.5
4
4
  Summary: A simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
7
7
  Author-email: orisui@icloud.com
8
- License: UNKNOWN
9
8
  Project-URL: Github, https://github.com/tinqlo/logfly
10
- Platform: UNKNOWN
11
9
  Classifier: Programming Language :: Python :: 3
12
10
  Classifier: License :: OSI Approved :: MIT License
13
11
  Classifier: Operating System :: OS Independent
@@ -53,5 +51,3 @@ if use hidden, log will also appear in user/.1o9f1y folder.
53
51
  #### Description
54
52
  pathfile is the file path that you want to create, must fill with '//'
55
53
  filenname is the file name that you want to create, must is with '*.*'
56
-
57
-
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="logfly",
8
- version="2.4",
8
+ version="2.5",
9
9
  author="Yuan Sui",
10
10
  author_email="orisui@icloud.com",
11
11
  description="A simple log tool by python",
@@ -1,14 +1,17 @@
1
1
  #####################
2
2
  # Author: Yuki Sui
3
- # Date: 2022-5-1
3
+ # Date: 2023-8-7
4
4
  #####################
5
5
 
6
6
  import time
7
7
  import shutil
8
8
  import os
9
9
  from pathlib import Path
10
+ import subprocess
11
+
10
12
  try:
11
13
  from colorama import init
14
+
12
15
  __colorama_init__ = True
13
16
  except ModuleNotFoundError:
14
17
  __colorama_init__ = False
@@ -19,7 +22,7 @@ if __colorama_init__:
19
22
  else:
20
23
  pass
21
24
 
22
- __version__ = '2.4'
25
+ __version__ = '2.5'
23
26
 
24
27
 
25
28
  def create_or_check_file(pathorfile, name, warning='yes'):
@@ -172,6 +175,8 @@ def write_log(name, position, level, message, mode='add',
172
175
  File = open(LOGFILE2, 'a', newline='', encoding='utf-8')
173
176
  File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
174
177
  File.close()
178
+ elif hidden == 'no':
179
+ pass
175
180
  else:
176
181
  mesg = str(message) + '\r\n\r\n'
177
182
  print(mesg)
@@ -259,7 +264,25 @@ def mv_file(original_file_name, new_file_name, folder_name='mv_file'):
259
264
  write_log('logfly-log', 'CLI', 'error', message, folder_name=folder_name)
260
265
 
261
266
 
262
- def error(exp,linenum, mode='logfly'):
267
+ def run_cmd(cmd):
268
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
269
+ while True:
270
+ result = p.stdout.readline() # 默认获取到的是二进制内容
271
+ if result != b'': # 获取内容不为空时
272
+ try:
273
+ print(result.decode('gbk').strip('\r\n')) # 处理GBK编码的输出,去掉结尾换行
274
+ write_log('logfly-log', 'file', 'info', message=result.decode('gbk').strip('\r\n'))
275
+ return result.decode('gbk').strip('\r\n')
276
+ except Exception as e:
277
+ print(e)
278
+ print(result.decode('utf-8').strip('\r\n')) # 如果GBK解码失败再尝试UTF-8解码
279
+ write_log('logfly-log', 'file', 'info', message=result.decode('utf-8').strip('\r\n'))
280
+ return result.decode('utf-8').strip('\r\n')
281
+ else:
282
+ break
283
+
284
+
285
+ def error(exp, linenum, mode='logfly'):
263
286
  if mode == 'logfly':
264
287
  logflyErrorMessage = 'ERROR occurred! at row ' + str(linenum) + '\r\n\r\n' + str(
265
288
  exp) + "\r\n\r\nplease re-check it! \r\nAnd you can see the " \
@@ -278,4 +301,5 @@ class ParameterERROR(Exception):
278
301
 
279
302
 
280
303
  if __name__ == '__main__':
281
- write_log('logfly-log', 'CLI', 'pass', 'test', hidden='yes')
304
+ # write_log('logfly-log', 'CLI', 'pass', 'test', hidden='yes')
305
+ run_cmd("echo 111111")
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 2.4
3
+ Version: 2.5
4
4
  Summary: A simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
7
7
  Author-email: orisui@icloud.com
8
- License: UNKNOWN
9
8
  Project-URL: Github, https://github.com/tinqlo/logfly
10
- Platform: UNKNOWN
11
9
  Classifier: Programming Language :: Python :: 3
12
10
  Classifier: License :: OSI Approved :: MIT License
13
11
  Classifier: Operating System :: OS Independent
@@ -53,5 +51,3 @@ if use hidden, log will also appear in user/.1o9f1y folder.
53
51
  #### Description
54
52
  pathfile is the file path that you want to create, must fill with '//'
55
53
  filenname is the file name that you want to create, must is with '*.*'
56
-
57
-
File without changes
File without changes
File without changes
File without changes