本文整理汇总了Python中system.system函数的典型用法代码示例。如果您正苦于以下问题:Python system函数的具体用法?Python system怎么用?Python system使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了system函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: restart
def restart(self):
yield self._lock.acquire()
try:
yield system.system('ifconfig', self.iface, '0.0.0.0')
yield system.system('ifconfig', self.iface, 'down')
finally:
self._lock.release()
开发者ID:PR2,项目名称:linux_networking,代码行数:7,代码来源:interface_upper.py
示例2: _locked_cb
def _locked_cb(self, old_state, new_state):
if self._iface_status_pub.get() >= IFSTATE.PLUGGED:
yield system.system('ip', 'route', 'flush', 'table', self.table, 'dev', self.iface)
if new_state:
gateway = new_state['gateway']
ip = new_state['ip']
network_slashed = new_state['network_slashed']
yield system.system('ip', 'route', 'add', 'table', self.table, 'default', 'dev', self.iface, 'via', gateway, 'src', ip, 'onlink')
yield system.system('ip', 'route', 'add', 'table', self.table, network_slashed, 'dev', self.iface, 'src', ip)
开发者ID:PR2,项目名称:linux_networking,代码行数:10,代码来源:dhcp_apply_config.py
示例3: __init__
def __init__(self):
self.interfaces = {}
self.update_event = event.Event()
self.update_interval = 1
self.radio_manager = radio_manager.RadioManager()
self.inactive_penalty = config.get_parameter('inactive_penalty', 50)
self.forced_interface = ""
self.tunnel_interface = config.get_parameter('tunnel_interface', "")
self.use_tunnel = True
self.active_interfaces = []
self.basestation = config.get_parameter('base_station')
# print "Resolving basestation IP. (Blocking operation.)"
# self.basestation_ip = socket.gethostbyname(config.get_parameter('base_station'))
# Add rules to guarantee that local routes go to the main table.
# self.local_net_rule = ip_rule.IpRule(RULEID.LOCAL)
# for subnet in config.get_parameter('local_networks'):
# self.local_net_rule.add('to', subnet, 'lookup', 'main')
self.local_net_rules = []
for (i, subnet) in enumerate(config.get_parameter('local_networks')):
self.local_net_rules.append(ip_rule.IpRule(RULEID.LOCAL+i))
self.local_net_rules[i].add('to', subnet, 'lookup', 'main')
# Add a rule to send through the vpn.
if self.tunnel_interface:
self.vpn_rule = ip_rule.IpRule(RULEID.DEFAULT)
# Use LINK here because netlink_monitor's parsing rules don't
# currently work on vpn interfaces.
system.system('ip', 'route', 'flush', 'table', str(RULEID.DEFAULT))
netlink_monitor.get_state_publisher(self.tunnel_interface,
IFSTATE.LINK).subscribe(self._refresh_default_route)
# Create all the interfaces.
interface_names = config.get_parameter('interfaces').keys()
ifaceid = RULEID.FIRST_IFACE
for iface in interface_names:
try:
new_iface = self.interfaces[iface] = interface.construct(iface, ifaceid)
new_iface.score = InterfaceSelector.TERRIBLE_INTERFACE
new_iface.prescore = InterfaceSelector.TERRIBLE_INTERFACE
ifaceid += 1
except interface.NoType:
print >> sys.stderr, "Interface %s has no type."%iface
sys.exit(1)
except interface.UnknownType, e:
print >> sys.stderr, "Interface %s has unknown type %s."%(iface, e)
sys.exit(1)
except:
开发者ID:PR2,项目名称:linux_networking,代码行数:51,代码来源:interface_selector.py
示例4: UpdateDB
def UpdateDB(corp, victims) :
chars = corp.chars
systems = corp.systems
NewNotifs = []
for name, char in chars.items() :
print("Loading data for " + name + "...")
NewNotifs += char.GetNotifications()
#NewNotifs = NewNotifs + char.GetNotifications()
ProcessKills(NewNotifs, victims)
for n in NewNotifs :
if n.system not in corp.systems :
corp.systems[n.system] = system.system(n.system, corp.ID)
if n.type == 'plex' :
n.char.addPlex(n)
corp.addPlex(n)
corp.systems[n.system].addPlex(n)
if n.type == 'kill' :
corp.systems[n.system].addKill(n)
n.char.addKill(n)
corp.addKill(n)
for i in [chars, systems] :
for k, v in i.items() :
v.save()
corp.save()
开发者ID:NikolaiAgnon,项目名称:plexbox,代码行数:29,代码来源:plexers.py
示例5: main
def main():
app = system.system()
app.setup()
#app.switch_mode(mode.play.play())
app.switch_mode(mode.menu.menu())
app.run()
开发者ID:srynot4sale,项目名称:farming,代码行数:7,代码来源:main.py
示例6: eddieguts
def eddieguts(Config, eddieHistory):
# instantiate a process list
log.log( "<eddie>eddieguts(), creating process object", 8 )
directive.plist = proc.procList()
# instantiate a disk usage list
log.log( "<eddie>eddieguts(), creating df object", 8 )
directive.dlist = df.dfList()
# instantiate a netstat list
log.log( "<eddie>eddieguts(), creating netstat object", 8 )
directive.nlist = netstat.netstat()
# instantiate a system object
log.log( "<eddie>eddieguts(), creating system object", 8 )
directive.system = system.system()
if module_iostat:
# instantiate an iostat object
log.log( "<eddie>eddieguts(), creating iostat object", 8 )
directive.iostat = iostat.iostat()
# Now do all the checking
log.log( "<eddie>eddieguts(), beginning checks", 7 )
check(Config)
# Save history (debug.. FS only for now...)
eddieHistory.save('FS',directive.dlist)
开发者ID:hexdump42,项目名称:eddie-tool,代码行数:29,代码来源:eddie.py
示例7: GET
def GET(self):
import system
data = system.system().GetConcifInfo()
data['siteCount'] = public.M('sites').count()
data['ftpCount'] = public.M('ftps').count()
data['databaseCount'] = public.M('databases').count()
data['lan'] = public.getLan('index')
return render.index(data)
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:8,代码来源:main.py
示例8: _cb
def _cb(self, old_state, new_state):
plugged, up = new_state
self.state = new_state
if plugged and not up and not self._is_shutdown:
yield self._lock.acquire()
try:
yield system.system('ifconfig', self.iface, 'up')
finally:
self._lock.release()
开发者ID:PR2,项目名称:linux_networking,代码行数:9,代码来源:interface_upper.py
示例9: _set_or_add
def _set_or_add(self, remove_old, args):
"""Changes/adds the rule. Call with no arguments to clear the rule."""
if self.is_shutdown:
return
yield self._lock.acquire()
try:
# Are we replacing a rule with itself?
if remove_old and self.prev and args == self.prev:
return
# Add new rule
if args:
yield system.system('ip', 'rule', 'add', "priority", self.priority, *args)
# Add remove old rule
if self.prev and remove_old:
yield system.system('ip', 'rule', 'del', "priority", self.priority, *self.prev)
self.prev = args
self.state_pub.set(args)
finally:
self._lock.release()
开发者ID:PR2,项目名称:linux_networking,代码行数:20,代码来源:ip_rule.py
示例10: flush
def flush(self):
self.prev = () # Won't hurt to do it here, just means we might not
# delete during ongoing set. Ensures it is set at
# end of construction.
yield self._lock.acquire()
try:
retcode = None
while not retcode:
retcode = yield system.system(system.Quiet, 'ip', 'rule', 'del', 'priority', self.priority)
finally:
self._lock.release()
开发者ID:PR2,项目名称:linux_networking,代码行数:11,代码来源:ip_rule.py
示例11: LoadSystems
def LoadSystems(corpid, fpath = vars.systems) :
systems = {}
for fname in os.listdir(fpath + corpid + '/systems/') :
try :
with open(fpath + corpid + '/systems/' + fname, 'r') as file :
js = json.load(file)
newsys = system.system(js['name'], corpid)
systems[js['name']] = newsys
finally :
pass
return systems
开发者ID:NikolaiAgnon,项目名称:plexbox,代码行数:11,代码来源:persistence.py
示例12: initialize
def initialize():
pl.close('all')
global info, network, system, traces, torus, sweepingPhasespace
reload(model)
info = nf.info()
network = netw.network(info=info)
system = sys.system(info=info, network=network)
traces = tra.traces(system, network, info=info)
torus = tor.torus(system, network, traces, info=info)
network.system = system
system.traces = traces
## customize system for web
system.setParams(epsilon=0.3)
system.ax.set_xlabel(r'Inactivation Variable')
system.ax.set_ylabel(r'Voltage Variable')
system.ax.set_title('')
system.fig.tight_layout()
plugins.connect(system.fig, DragPlugin(eventHandlerURL="updatesystem", radioButtonID="systemRadio"))
# customize network
network.ax.patch.set_facecolor('#777777')
network.moveText(2, [0.02, -0.1])
network.moveText(3, [0.02, -0.1])
network.ax.texts[6].set_text('1')
network.ax.texts[7].set_text('2')
network.ax.texts[8].set_text('3')
plugins.connect(network.fig, DragPlugin(eventHandlerURL="updatenetwork", radioButtonID="networkRadio"))
# customize traces
traces.ax.patch.set_facecolor('#777777')
traces.fig.tight_layout()
# customize torus
torus.ax_traces.set_xlabel(r'phase lag: 1-2')
torus.ax_basins.set_xlabel(r'phase lag: 1-2')
torus.ax_traces.set_ylabel(r'phase lag: 1-3')
torus.fig.tight_layout()
torus.switch_processor() # switches on the gpu if available
if torus.USE_GPU: torus.setGridsize(24)
plugins.connect(torus.fig, ClickPlugin(eventHandlerURL="updatetorus", radioButtonID="torusRadio"))
# reload timing variable
sweepingPhasespace = False;
开发者ID:jusjusjus,项目名称:Motiftoolbox,代码行数:46,代码来源:webrun.py
示例13: GetSshInfo
def GetSshInfo(self,get):
file = '/etc/ssh/sshd_config'
conf = public.readFile(file)
rep = "#*Port\s+([0-9]+)\s*\n"
port = re.search(rep,conf).groups(0)[0]
import system
panelsys = system.system();
version = panelsys.GetSystemVersion();
if not os.path.exists('/etc/redhat-release'):
status = public.ExecShell("service ssh status | grep 'dead'")
else:
if version.find(' 7.') != -1:
status = public.ExecShell("systemctl status sshd.service | grep 'dead'")
else:
status = public.ExecShell("/etc/init.d/sshd status | grep -e 'stopped' -e '已停'")
# return status;
if len(status[0]) > 3:
status = False
else:
status = True
isPing = True
try:
file = '/etc/sysctl.conf'
conf = public.readFile(file)
rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)"
tmp = re.search(rep,conf).groups(0)[0]
if tmp == '1': isPing = False
except:
isPing = True
data = {}
data['port'] = port
data['status'] = status
data['ping'] = isPing
return data
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:39,代码来源:firewalls.py
示例14: testCpu
def testCpu(self,get,n = 1):
data = {}
data['cpuCount'] = psutil.cpu_count();
if not hasattr(get,'type'): get.type = '0';
import re;
cpuinfo = open('/proc/cpuinfo','r').read();
rep = "model\s+name\s+:\s+(.+)"
tmp = re.search(rep,cpuinfo);
data['cpuType'] = ""
if tmp:
data['cpuType'] = tmp.groups()[0];
import system
data['system'] = system.system().GetSystemVersion();
path = '/www/server/panel/plugin/score/testcpu';
if not os.path.exists(path): os.system('gcc '+path+'.c -o ' +path + ' -lpthread');
start = time.time();
os.system(path + ' 32 ' + get.type);
end = time.time();
data['score'] = int(400 * 10 / (end - start));
if not os.path.exists(path): data['score'] = 0;
self.writeScore('cpu'+get.type, data['score'])
return data;
pass
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:24,代码来源:score_main.py
示例15: UpdatePanel
def UpdatePanel(self,get):
#return public.returnMsg(False,'演示服务器,禁止此操作!');
try:
if not public.IsRestart(): return public.returnMsg(False,'EXEC_ERR_TASK');
import web,json
if int(web.ctx.session.config['status']) == 0:
public.httpGet(web.ctx.session.home+'/Api/SetupCount?type=Linux');
public.M('config').where("id=?",('1',)).setField('status',1);
#取回远程版本信息
if hasattr(web.ctx.session,'updateInfo') == True and hasattr(get,'check') == False:
updateInfo = web.ctx.session.updateInfo;
else:
login_temp = 'data/login.temp';
if os.path.exists(login_temp):
logs = public.readFile(login_temp)
os.remove(login_temp);
else:
logs = '';
import psutil,panelPlugin,system;
mem = psutil.virtual_memory();
mplugin = panelPlugin.panelPlugin();
mplugin.ROWS = 10000;
panelsys = system.system();
data = {}
data['sites'] = str(public.M('sites').count());
data['ftps'] = str(public.M('ftps').count());
data['databases'] = str(public.M('databases').count());
data['system'] = panelsys.GetSystemVersion() + '|' + str(mem.total / 1024 / 1024) + 'MB|' + public.getCpuType() + '*' + str(psutil.cpu_count()) + '|' + public.get_webserver() + '|' + web.ctx.session.version;
data['system'] += '||'+self.GetInstalleds(mplugin.getPluginList(None));
data['logs'] = logs
data['oem'] = ''
data['intrusion'] = self.get_ssh_intrusion();
msg = public.getMsg('PANEL_UPDATE_MSG');
sUrl = web.ctx.session.home + '/Api/updateLinux';
betaIs = 'data/beta.pl';
betaStr = public.readFile(betaIs);
if betaStr:
if betaStr.strip() != 'False':
sUrl = web.ctx.session.home + '/Api/updateLinuxBeta';
msg = public.getMsg('PANEL_UPDATE_MSG_TEST');
betaIs = 'plugin/beta/config.conf';
betaStr = public.readFile(betaIs);
if betaStr:
if betaStr.strip() != 'False':
sUrl = web.ctx.session.home + '/Api/updateLinuxBeta';
msg = public.getMsg('PANEL_UPDATE_MSG_TEST');
updateInfo = json.loads(public.httpPost(sUrl,data));
if not updateInfo: return public.returnMsg(False,"CONNECT_ERR");
updateInfo['msg'] = msg;
web.ctx.session.updateInfo = updateInfo;
#检查是否需要升级
if updateInfo['version'] == web.ctx.session.version:
try:
return public.returnMsg(False,updateInfo['msg']);
except:
return public.returnMsg(False,'PANEL_UPDATE_ERR_NEW');
#是否执行升级程序
if(updateInfo['force'] == True or hasattr(get,'toUpdate') == True or os.path.exists('data/autoUpdate.pl') == True):
setupPath = web.ctx.session.setupPath;
uptype = 'update';
betaIs = 'plugin/beta/config.conf';
betaStr = public.readFile(betaIs);
if betaStr:
if betaStr.strip() != 'False': uptype = 'updateTest';
betaIs = 'data/beta.pl';
betaStr = public.readFile(betaIs);
if betaStr:
if betaStr.strip() != 'False': uptype = 'updateTest';
httpUrl = public.get_url();
if httpUrl: updateInfo['downUrl'] = httpUrl + '/install/' + uptype + '/LinuxPanel-' + updateInfo['version'] + '.zip';
public.downloadFile(updateInfo['downUrl'],'panel.zip');
if os.path.getsize('panel.zip') < 1048576: return public.returnMsg(False,"PANEL_UPDATE_ERR_DOWN");
public.ExecShell('unzip -o panel.zip -d ' + setupPath + '/');
import compileall
if os.path.exists(setupPath + '/panel/main.py'): public.ExecShell('rm -f ' + setupPath + '/panel/*.pyc');
if os.path.exists(setupPath + '/panel/class/common.py'): public.ExecShell('rm -f ' + setupPath + '/panel/class/*.pyc');
compileall.compile_dir(setupPath + '/panel');
compileall.compile_dir(setupPath + '/panel/class');
public.ExecShell('rm -f panel.zip');
web.ctx.session.version = updateInfo['version']
return public.returnMsg(True,'PANEL_UPDATE',(updateInfo['version'],));
#输出新版本信息
data = {
'status' : True,
'version': updateInfo['version'],
'updateMsg' : updateInfo['updateMsg']
};
public.ExecShell('rm -rf /www/server/phpinfo/*');
return data;
except Exception,ex:
#.........这里部分代码省略.........
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:101,代码来源:ajax.py
示例16: range
state6 = statements.get_takeValue('L1')
state7 = statements.get_takeValue('L2')
state8 = statements.get_takeValue('L3')
state9 = statements.get_takeValue('L4')
boolStatements = [state2,state3,state4,state5]
numStatements = [state0,state1,state6,state7,state8,state9]
slist = [createSample_prejudiced() for i in range(1000)]
numparams= ['A','B','L1','L2','L3','L4']
boolparams = ['O','C1','C2','G']
keyparams = ['R','C']
import time
import system
t = time.time()
sys = system.system(keyparams,boolparams,numparams,slist,6000,300,15)
keyStates =sys.keyStatements
import helpers
sysLog = helpers.logWriter()
sysDump = helpers.logWriter()
sys.setLogWriter(sysLog)
sys.setDumpWriter(sysDump)
def runSimulation(rounds = 100,tests = 500):
sys.initialise()
sysLog.printToConsole()
num = tests
flog = open("lastLog.log",'w')
fdump = open("lastDump.log",'w')
开发者ID:justheuristic,项目名称:GraveRobot,代码行数:31,代码来源:debug_version.py
示例17:
import system as sys
import network3N as netw
import traces as tra
import info as nf
import torus as tor
import pylab as pl
pos_info = '+0+600'
pos_tra = '+300+600'
pos_net = '+300+0'
pos_sys = '+0+0'
pos_torus = '+800+0'
info = nf.info(position=pos_info)
net = netw.network(g_inh=0.015, info=info, position=pos_net)
system = sys.system(info=info, position=pos_sys, network=net)
traces = tra.traces(system, net, info=info, position=pos_tra)
torus = tor.torus(system, net, traces, info=info, position=pos_torus)
net.system = system
system.traces = traces
if pl.get_backend() == 'TkAgg':
system.fig.tight_layout()
traces.fig.tight_layout()
torus.fig.tight_layout()
pl.show()
开发者ID:jusjusjus,项目名称:Motiftoolbox,代码行数:28,代码来源:run.py
示例18:
from parameter import parameter
from system import system
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from datetime import datetime
from selenium.webdriver.support.ui import WebDriverWait
import logging
import os
system=system()
parameter=parameter()
parameter.textinput()
parameter.tel()
driver=webdriver.Firefox()
logging.info('open url')
driver.get_screenshot_as_file(system.FileName())
开发者ID:liumeixia,项目名称:xiaworkspace,代码行数:16,代码来源:run.py
示例19:
#!/usr/bin/env python
import system as sys
import traces as tra
import info as nf
import pylab as pl
pos_info = '+0+600'
pos_tra = '+300+600'
pos_sys = '+0+0'
i = nf.info(position=pos_info)
s = sys.system(info=i, position=pos_sys)
t = tra.traces(s, info=i, position=pos_tra)
if pl.get_backend() == 'TkAgg':
s.fig.tight_layout()
t.fig.tight_layout()
pl.show()
开发者ID:RamiJacob,项目名称:Motiftoolbox,代码行数:22,代码来源:run.py
示例20: get_service_info
def get_service_info(self,get):
import system;
serviceInfo = system.system().GetConcifInfo(get);
del(serviceInfo['mysql_root']);
return serviceInfo;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:5,代码来源:safelogin_main.py
注:本文中的system.system函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论