11# -- coding:utf-8 --
22
3+ import datetime
34# import logging
45import os
6+ import platform
57import time
8+ import sys
69import subprocess
7- import platform
10+
811from com .dvsnier .directory .common_dir import generate_complex_file_name
9- import datetime
1012
1113
1214def execute (cmds , quiet = True ):
@@ -17,10 +19,7 @@ def execute(cmds, quiet=True):
1719 # (p.pid, os.getppid(), type(p), id(p)))
1820 processes = [p ]
1921 for x in cmds [1 :]:
20- p = subprocess .Popen (x ,
21- stdin = p .stdout ,
22- stdout = subprocess .PIPE ,
23- shell = True )
22+ p = subprocess .Popen (x , stdin = p .stdout , stdout = subprocess .PIPE , shell = True )
2423 # logging.debug(
2524 # 'the current sub process pid(cwd: %s, ppid: %s, id: %s%d).' %
2625 # (p.pid, os.getppid(), type(p), id(p)))
@@ -39,7 +38,11 @@ def execute(cmds, quiet=True):
3938 print ('\r ' ),
4039 msg = '[%.5f] -> %s' % (end - start , ' | ' .join (cmds ))
4140 print (msg )
42- content = output .rstrip ('\n ' )
41+ content = ''
42+ if sys .version_info .major > 2 :
43+ content = str (output .rstrip (bytes ('\n ' , encoding = 'utf-8' )))
44+ else :
45+ content = output .rstrip ('\n ' )
4346 # logging.debug('the current run process pid(cwd: %s, ppid: %s, id: %s%d).' %
4447 # (p.pid, os.getppid(), type(p), id(p)))
4548 return content
@@ -57,11 +60,8 @@ def trace(cmds):
5760 file .write ('\n ' )
5861 file .write (
5962 str ('the current timestamp: {timestamp}\n ' .format (
60- timestamp = datetime .datetime .now ().strftime (
61- '%Y-%m-%d %H:%M:%S.%f' ))))
62- file .write (
63- str ('the current command: [{cmd}].\n ' .format (
64- cmd = ' | ' .join (command ))))
63+ timestamp = datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M:%S.%f' ))))
64+ file .write (str ('the current command: [{cmd}].\n ' .format (cmd = ' | ' .join (command ))))
6565 # file.write(execute(command, quiet=False))
6666 file .write (execute (command , quiet = True ))
6767 file .write ('\n ' )
0 commit comments