Server IP : 85.214.239.14 / Your IP : 3.137.221.252 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/proc/3/root/proc/2/task/2/root/usr/share/python3/debpython/ |
Upload File : |
try: from datetime import datetime except ImportError: datetime = None import logging import re from subprocess import PIPE, Popen from pickle import dumps log = logging.getLogger(__name__) PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d(?:.\d+)?)/(site|dist)-packages') class memoize: def __init__(self, func): self.func = func self.cache = {} def __call__(self, *args, **kwargs): key = dumps((args, kwargs)) if key not in self.cache: self.cache[key] = self.func(*args, **kwargs) return self.cache[key] def execute(command, cwd=None, env=None, log_output=None): """Execute external commad. :param cdw: currennt working directory :param env: environment :param log_output: * opened log file or path to this file, or * None if output should be included in the returned dict, or * False if output should be redirectored to stdout/stderr """ args = {'shell': False, 'cwd': cwd, 'env': env} close = False if log_output is False: pass elif log_output is None: args.update(stdout=PIPE, stderr=PIPE) elif log_output: if isinstance(log_output, str): close = True log_output = open(log_output, 'a') if datetime: log_output.write('\n# command executed on {}'.format(datetime.now().isoformat())) log_output.write('\n$ {}\n'.format(repr(command))) log_output.flush() args.update(stdout=log_output, stderr=log_output) log.debug('invoking: %r', command) with Popen(command, **args) as process: stdout, stderr = process.communicate() close and log_output.close() return dict(returncode=process.returncode, stdout=stdout and str(stdout, 'utf-8'), stderr=stderr and str(stderr, 'utf-8'))