本文整理汇总了Python中utils.platform函数的典型用法代码示例。如果您正苦于以下问题:Python platform函数的具体用法?Python platform怎么用?Python platform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了platform函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: WriteConfiguration
def WriteConfiguration(server, dest, authPath):
root = os.path.join(HOME, 'resources', 'configs')
config = os.path.join(root, 'cfg.ovpn')
cert = os.path.join(root, 'vpn.crt')
port = ADDON.getSetting('PORT')
file = open(config, mode='r')
content = file.read()
file.close()
authPath = authPath.replace('\\', '/')
cert = cert.replace('\\', '/')
content = content.replace('#SERVER#', server)
content = content.replace('#PORT#', port)
if utils.platform() == 'android':
authentication = '<auth-user-pass>\r\n' \
+ ADDON.getSetting('USER') + '@vpnicity' + '\r\n' \
+ ADDON.getSetting('PASS') + '\r\n' \
+ '</auth-user-pass>'
else:
authentication = 'auth-user-pass "%s"' % authPath
content = content.replace('#AUTHENTICATION#', authentication)
file = open(dest, mode='w')
file.write(content)
file.close()
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:30,代码来源:vpn.py
示例2: KillVPN
def KillVPN():
xbmcgui.Window(10000).clearProperty('VPNICITY_LABEL')
xbmcgui.Window(10000).clearProperty('VPNICITY_ABRV')
xbmcgui.Window(10000).clearProperty('VPNICITY_SERVER')
if os.name == 'nt':
try:
si = subprocess.STARTUPINFO
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess._subprocess.SW_HIDE
ps = subprocess.Popen('TASKKILL /F /IM openvpn.exe', shell=True, stdout=subprocess.PIPE, startupinfo=None)
ps.wait()
except:
pass
return
# Android
if utils.platform() == "android" :
xbmc.executebuiltin( "StartAndroidActivity(%s,%s)" % ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.DISCONNECT") )
return
#LINUX
try:
cmd = utils.getSudo() + 'killall -9 openvpn'
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
ps.wait()
except:
pass
开发者ID:Xycl,项目名称:spoyser-repo,代码行数:30,代码来源:kill.py
示例3: test_no_avx_instructions
def test_no_avx_instructions(self):
if platform() == "darwin":
tool = "otool -tV"
else:
tool = "objdump -d"
proc = subprocess.call(
"%s %s | grep vxorps" % (tool, self.binary), shell=True)
# Require no AVX instructions
self.assertEqual(proc, 1)
开发者ID:bonifiedallday,项目名称:osquery,代码行数:9,代码来源:test_release.py
示例4: test_no_local_link
def test_no_local_link(self):
if platform() == "darwin":
tool = "otool -L"
else:
tool = "ldd"
proc = subprocess.call(
"%s %s | grep /usr/local/" % (tool, self.binary), shell=True)
# Require no local dynamic dependent links.
self.assertEqual(proc, 1)
开发者ID:bonifiedallday,项目名称:osquery,代码行数:9,代码来源:test_release.py
示例5: get_stats
def get_stats(p, interval=1):
"""Run psutil and downselect the information."""
utilization = p.cpu_percent(interval=interval)
return {
"utilization": utilization,
"counters": p.io_counters() if utils.platform() != "darwin" else None,
"fds": p.num_fds(),
"cpu_times": p.cpu_times(),
"memory": p.memory_info_ex(),
}
开发者ID:runt18,项目名称:osquery,代码行数:10,代码来源:profile.py
示例6: VPN
def VPN(label, abrv, server):
authPath = os.path.join(PROFILE, 'temp')
cfgPath = os.path.join(PROFILE, 'cfg.ovpn')
KillVPN(silent=True)
WriteAuthentication(authPath)
WriteConfiguration(server, cfgPath, authPath)
busy = utils.showBusy()
response = OpenVPN(cfgPath)
if busy:
busy.close()
success = True
if response:
label = label.rsplit(' (', 1)[0]
if IsEnabled(response):
if utils.platform() == "android":
xbmc.sleep(10000)
utils.dialogOK('%s %s now enabled' % (label, TITLE))
xbmcgui.Window(10000).setProperty('VPNICITY_LABEL', label)
xbmcgui.Window(10000).setProperty('VPNICITY_ABRV', abrv)
xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server)
ipcheck.Network()
else:
KillVPN(silent=True)
if utils.platform() == "android":
xbmc.sleep(5000)
utils.dialogOK('%s %s failed to start' % (label, TITLE), 'Please check your settings', 'and try again')
ipcheck.Network()
success = False
#DeleteFile(authPath)
#DeleteFile(cfgPath)
#DeleteFile(RESPONSE)
return success
开发者ID:Xycl,项目名称:spoyser-repo,代码行数:42,代码来源:vpn.py
示例7: Run
def Run(cmdline, timeout=0):
if utils.platform() == "android":
xbmc.executebuiltin( cmdline )
return 'Initialization Sequence Completed'
#print "COMMAND - %s" % cmdline
ret = 'Error: Process failed to start'
if timeout > 0:
path = RESPONSE
shell = True
si = None
if os.name == 'nt':
shell = False
si = subprocess.STARTUPINFO
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess._subprocess.SW_HIDE
f = open(path, mode='w')
ps = subprocess.Popen(cmdline, shell=shell, stdout=f, startupinfo=si)
xbmc.sleep(5000)
while timeout > 0:
xbmc.sleep(1000)
timeout -= 1
f1 = open(path, mode='r')
ret = f1.read()
f1.close()
if IsEnabled(ret) or IsDisabled(ret):
timeout = 0
f.close()
else:
ps = subprocess.Popen(cmdline, shell=False, stdout=subprocess.PIPE)
ret = ps.stdout.read()
ps.stdout.close()
#try:
# print "RESULT - %s" % str(ret)
#except:
# pass
return ret
开发者ID:Xycl,项目名称:spoyser-repo,代码行数:50,代码来源:vpn.py
示例8: VPN
def VPN(label, abrv, server):
if not validToRun():
utils.log('Login Error via Context Menu')
return False
authPath = os.path.join(PROFILE, 'temp')
cfgPath = os.path.join(PROFILE, 'cfg.ovpn')
KillVPN(silent=True)
WriteAuthentication(authPath)
WriteConfiguration(server, cfgPath, authPath)
busy = utils.showBusy()
response = OpenVPN(cfgPath)
if busy:
busy.close()
success = True
if response:
label = label.rsplit(' (', 1)[0]
if IsEnabled(response):
# if utils.platform() == "android":
# xbmc.sleep(10000)
message = '%s %s now enabled' % (label, TITLE)
utils.notify(message)
xbmcgui.Window(10000).setProperty('VPNICITY_LABEL', label)
xbmcgui.Window(10000).setProperty('VPNICITY_ABRV', abrv)
xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server)
ipcheck.Network()
else:
KillVPN(silent=True)
if utils.platform() == "android":
xbmc.sleep(5000)
message = '%s %s failed to start. Please check your settings.' % (label, TITLE)
utils.notify(message)
ipcheck.Network()
success = False
#DeleteFile(authPath)
#DeleteFile(cfgPath)
#DeleteFile(RESPONSE)
return success
开发者ID:Nemeziz,项目名称:Dixie-Deans-XBMC-Repo,代码行数:48,代码来源:vpn.py
示例9: OpenVPN
def OpenVPN(config):
import path
exe = path.getPath(ADDON.getSetting('OS'))
if not exe:
return None
try: timeout = int(ADDON.getSetting('TIMEOUT'))
except: timeout = 99999
if utils.platform() == "android":
cmdline = "StartAndroidActivity(%s,%s,%s,%s)" % \
( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.CONNECT", "com.vpnicity.openvpn.control.PROFILE_PATH", "file://" + config )
else :
cmdline = utils.getSudo()
cmdline += '"' + exe + '"'
cmdline += ' '
cmdline += '"' + config + '"'
cmdline = cmdline.replace('\\', '/')
return Run(cmdline, timeout)
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:21,代码来源:vpn.py
示例10: WriteAuthentication
def WriteAuthentication(path):
# CheckUsername()
user = USERNAME + '@vpnicity'
pwd = PASSWORD
if user == '' and pwd == '':
return
f = open(path, mode='w')
if utils.platform() == 'osx':
f.write(user)
f.write('\n')
f.write(pwd)
f.write('\n')
f.close()
else:
f.write(user)
f.write('\r\n')
f.write(pwd)
f.write('\r\n')
f.close()
开发者ID:Nemeziz,项目名称:Dixie-Deans-XBMC-Repo,代码行数:24,代码来源:vpn.py
示例11: WriteAuthentication
def WriteAuthentication(path):
CheckUsername()
user = ADDON.getSetting('USER') + '@vpnicity'
pwd = ADDON.getSetting('PASS')
if user == '' and pwd == '':
return
f = open(path, mode='w')
if utils.platform() == 'osx':
f.write(user)
f.write('\n')
f.write(pwd)
f.write('\n')
f.close()
else:
f.write(user)
f.write('\r\n')
f.write(pwd)
f.write('\r\n')
f.close()
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:24,代码来源:vpn.py
示例12: shell
group = parser.add_argument_group("Run Options:")
group.add_argument(
"--timeout", metavar="N", default=0, type=int,
help="Max seconds a query may run --count times."
)
group.add_argument(
"--count", metavar="N", default=1, type=int,
help="Run the query N times serially."
)
group.add_argument(
"--rounds", metavar="N", default=1, type=int,
help="Run the profile for N rounds and use the average."
)
group.add_argument(
"--shell", metavar="PATH", default="./build/%s/osquery/osqueryi" % (
utils.platform()),
help="Path to osqueryi shell (./build/<sys>/osquery/osqueryi)."
)
group.add_argument(
"--force", action="store_true", default=False,
help="Force run the target of shell",
)
group = parser.add_argument_group("Performance Options:")
group.add_argument(
"--output", metavar="FILE", default=None,
help="Write JSON performance output to file."
)
group.add_argument(
"--check", metavar="OLD_OUTPUT", nargs=1,
help="Check regressions using an existing output."
开发者ID:defaultnamehere,项目名称:osquery,代码行数:31,代码来源:profile.py
示例13: check_leaks
def check_leaks(shell, query, count=1, supp_file=None):
if utils.platform() == "darwin":
return check_leaks_darwin(shell, query, count=count)
else:
return check_leaks_linux(shell, query, count=count, supp_file=supp_file)
开发者ID:defaultnamehere,项目名称:osquery,代码行数:5,代码来源:profile.py
示例14: test_platform_specific_queries
def test_platform_specific_queries(self):
self._execute_set(PLATFORM_EXAMPLES[utils.platform()])
开发者ID:eastebry,项目名称:osquery,代码行数:2,代码来源:test_example_queries.py
示例15: platform
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.append(SCRIPT_DIR + "/../tests")
from utils import platform
# the log format for the logging module
LOG_FORMAT = "%(levelname)s [Line %(lineno)d]: %(message)s"
# Read all implementation templates
TEMPLATES = {}
# Temporary reserved column names
RESERVED = ["n", "index"]
# Set the platform in osquery-language
PLATFORM = platform()
# Supported SQL types for spec
class DataType(object):
def __init__(self, affinity, cpp_type="std::string"):
'''A column datatype is a pair of a SQL affinity to C++ type.'''
self.affinity = affinity
self.type = cpp_type
def __repr__(self):
return self.affinity
# Define column-type MACROs for the table specs
TEXT = DataType("TEXT_TYPE")
开发者ID:ArchieBitcoin,项目名称:osquery,代码行数:31,代码来源:gentable.py
示例16: test_platform_specific_queries
def test_platform_specific_queries(self):
posix = ["darwin", "linux"]
if utils.platform() in posix:
self._execute_set(PLATFORM_EXAMPLES["posix"])
self._execute_set(PLATFORM_EXAMPLES[utils.platform()])
开发者ID:Centurion89,项目名称:osquery,代码行数:5,代码来源:test_example_queries.py
示例17: shell
group = parser.add_argument_group("Query Options:")
group.add_argument("--restrict", metavar="LIST", default="", help="Limit to a list of comma-separated tables.")
group.add_argument("--tables", metavar="PATH", default="./specs", help="Path to the osquery table specs.")
group.add_argument("--config", metavar="FILE", default=None, help="Use scheduled queries from a config.")
group.add_argument("--query", metavar="STRING", default=None, help="Profile a single query.")
group = parser.add_argument_group("Run Options:")
group.add_argument("--timeout", metavar="N", default=0, type=int, help="Max seconds a query may run --count times.")
group.add_argument("--count", metavar="N", default=1, type=int, help="Run the query N times serially.")
group.add_argument(
"--rounds", metavar="N", default=1, type=int, help="Run the profile for N rounds and use the average."
)
group.add_argument(
"--shell",
metavar="PATH",
default="./build/%s/osquery/osqueryi" % (utils.platform()),
help="Path to osqueryi shell (./build/<sys>/osquery/osqueryi).",
)
group = parser.add_argument_group("Performance Options:")
group.add_argument("--output", metavar="FILE", default=None, help="Write JSON performance output to file.")
group.add_argument("--check", metavar="OLD_OUTPUT", nargs=1, help="Check regressions using an existing output.")
group.add_argument("--compare", metavar="FILE", nargs=2, help="Compare existing performance outputs (old, new).")
group = parser.add_argument_group("Memory Options:")
group.add_argument(
"--suppressions",
metavar="SUPP",
default="./tools/tests/osquery.supp",
help="Add a suppressions files to memory leak checking (linux only).",
)
开发者ID:kangkot,项目名称:osquery,代码行数:31,代码来源:profile.py
示例18: allowed_platform
def allowed_platform(qp):
if qp in ["all", "any"]:
return True
if len(qp) == 0:
return True
return qp.find(platform()) >= 0
开发者ID:bonifiedallday,项目名称:osquery,代码行数:6,代码来源:test_release.py
注:本文中的utils.platform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论