#!/usr/bin/python#coding:utf-8'''系统工具类'''import os,syscurPath = os.path.abspath(os.path.dirname(__file__))print('当前目录',curPath)def dealCommand(command):'''执行命令args:command:命令return:命令处理后列表'''# log.info(command)output = os.popen(command)result=output.readlines()result =[line.strip() for line in result]return resultdef runString(comm):'''执行系统命令,返回字符串'''r = os.popen(comm)msg=r.read()r.close()return msgdef timeout_command(command, timeout):'''执行系统命令command:命令timeout:超时时间,单位秒'''import subprocess, datetime, os, time, signalcmd = command.split(" ")start = datetime.datetime.now()process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)while process.poll() is None:time.sleep(0.2)now = datetime.datetime.now()if (now - start).seconds> timeout:os.kill(process.pid, signal.SIGKILL)os.waitpid(-1, os.WNOHANG)return Nonereturn process.stdout.readlines()def checkVersion():#python版本version=0 #0 python3 1 python2if sys.version_info < (3, 0):version=1print(version,"0:python3 1:python2")checkVersion()print("用户工作空间",os.getenv("userprofile"))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。