本文整理汇总了Python中sys.getwindowsversion函数的典型用法代码示例。如果您正苦于以下问题:Python getwindowsversion函数的具体用法?Python getwindowsversion怎么用?Python getwindowsversion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getwindowsversion函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_tiddler_locations
def get_tiddler_locations(store_contents, package_name):
"""
returns instance_tiddlers structure using tiddler paths from within the
package if available
store_structure is a dictionary listing tiddler URIs per bag
packaged tiddlers must be listed in <package>/resources/tiddlers.index
"""
package_path = os.path.join(*package_name.split("."))
tiddler_index = os.path.join("resources", "tiddlers.index")
tiddler_index = resource_filename(package_name, tiddler_index)
instance_tiddlers = {}
try:
f = open(tiddler_index)
for line in f:
bag, filename = line.rstrip().split("/", 1)
filepath = os.path.join("resources", bag, filename)
filepath = resource_filename(package_name, filepath)
try: # convert Windows paths to URIs
sys.getwindowsversion() # XXX: safer detection than sys.platform or os.name?
uri = "file:///%s" % filepath.replace("\\", "/")
except AttributeError:
uri = "file://%s" % filepath
resource_filename(package_name, "%s.meta" % filepath)
try:
instance_tiddlers[bag].append(uri)
except KeyError:
instance_tiddlers[bag] = [uri]
f.close()
except IOError:
for bag, uris in store_contents.items():
instance_tiddlers[bag] = uris
return instance_tiddlers
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.instancer,代码行数:34,代码来源:util.py
示例2: set_lowpriority
def set_lowpriority(pid):
""" Set the priority a process with pid to below-normal."""
import sys
try:
sys.getwindowsversion()
except:
isWindows = False
else:
isWindows = True
if isWindows:
# Based on:
# "Recipe 496767: Set Process Priority In Windows" on ActiveState
# http://code.activestate.com/recipes/496767/
#import win32api,win32process,win32con
#print("pid: "+str(pid))
#handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
#win32process.SetPriorityClass(handle, win32process.BELOW_NORMAL_PRIORITY_CLASS)
# currently. on Windows qprocess.pid() returns a void pointer, and not the process id
# hence, on Windows this is not implemented until finding a proper workaround
pass
else:
import os
os.system('renice -n 1 -p '+str(pid))
开发者ID:jasiegel4,项目名称:jerry,代码行数:27,代码来源:proc.py
示例3: _lowpriority
def _lowpriority():
""" Set the priority of the process to below-normal."""
import sys
try:
sys.getwindowsversion()
except AttributeError:
isWindows = False
else:
isWindows = True
if isWindows:
# Based on:
# "Recipe 496767: Set Process Priority In Windows" on ActiveState
# http://code.activestate.com/recipes/496767/
import win32api
import win32process
import win32con
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(
handle, win32process.BELOW_NORMAL_PRIORITY_CLASS,
)
else:
import os
os.nice(1)
开发者ID:white-lab,项目名称:pyproteome,代码行数:28,代码来源:motif.py
示例4: launch_ST2
def launch_ST2(self, files):
items = ["-n"] + files
cwd = None if NT else self.path
shell = False
if NT:
# 9200 means win8
shell = True if sys.getwindowsversion()[2] < 9200 else False
items = [i.encode(locale.getpreferredencoding(False)) if sys.getwindowsversion()[2] == 9200 else i for i in items]
def app_path():
if OSX:
app_path = subprocess.Popen(["osascript", "-e" "tell application \"System Events\" to POSIX path of (file of process \"Sublime Text 2\" as alias)"], stdout=subprocess.PIPE).communicate()[0].rstrip()
subl_path = "{0}/Contents/SharedSupport/bin/subl".format(app_path)
else:
subl_path = 'sublime_text'
yield subl_path
fail = False
for c in ['subl', 'sublime', app_path()]:
try:
subprocess.Popen(list(c) + items, cwd=cwd, shell=shell)
except:
fail = True
else:
fail = False
if fail:
sublime.status_message('Cannot open a new window')
开发者ID:DesruX,项目名称:SublimeFileBrowser,代码行数:28,代码来源:dired_misc.py
示例5: lowpriority
def lowpriority():
""" Set the priority of the process to below-normal.
Copied from: http://stackoverflow.com/questions/1023038/change-process-priority-in-python-cross-platform"""
try:
sys.getwindowsversion()
except:
isWindows = False
else:
isWindows = True
try:
if isWindows:
# Based on:
# "Recipe 496767: Set Process Priority In Windows" on ActiveState
# http://code.activestate.com/recipes/496767/
import win32api, win32process, win32con
pid = os.getpid()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, win32process.BELOW_NORMAL_PRIORITY_CLASS)
win32api.CloseHandle(handle)
else:
# Unix and Mac should have a nice function
os.nice(1)
except:
logger = logging.getLogger(__name__ + '.lowpriority')
if not logger is None:
logger.warn("Could not lower process priority")
if isWindows:
logger.warn("Are you missing Win32 extensions for python? http://sourceforge.net/projects/pywin32/")
pass
开发者ID:jamesra,项目名称:nornir-shared,代码行数:31,代码来源:misc.py
示例6: test_getwindowsversion
def test_getwindowsversion(self):
import sys
if hasattr(sys, "getwindowsversion"):
v = sys.getwindowsversion()
if '__pypy__' in sys.builtin_module_names:
assert isinstance(v, tuple)
assert len(v) == 5
assert isinstance(v[0], int)
assert isinstance(v[1], int)
assert isinstance(v[2], int)
assert isinstance(v[3], int)
assert isinstance(v[4], str)
assert v[0] == v.major
assert v[1] == v.minor
assert v[2] == v.build
assert v[3] == v.platform
assert v[4] == v.service_pack
assert isinstance(v.service_pack_minor, int)
assert isinstance(v.service_pack_major, int)
assert isinstance(v.suite_mask, int)
assert isinstance(v.product_type, int)
# This is how platform.py calls it. Make sure tuple still has 5
# elements
maj, min, buildno, plat, csd = sys.getwindowsversion()
开发者ID:yuyichao,项目名称:pypy,代码行数:27,代码来源:test_sysmodule.py
示例7: whatOSver
def whatOSver(self):
if sys.platform == 'win32':
self.osMajorver = str(sys.getwindowsversion()[0])
self.osMinorver = str(sys.getwindowsversion()[1])
self.osBuild = str(sys.getwindowsversion()[2])
self.osType = str(sys.getwindowsversion()[3])
self.osComments = str(sys.getwindowsversion()[4])
elif sys.platform == 'darwin':
self.osMajorver = '10'
osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"'
infopipe = os.popen(osxcmd, 'r')
parseLine = infopipe.read()
infopipe.close()
del infopipe
versionStringStart = parseLine.find('10.')
try:
self.osMinorver = parseLine[versionStringStart + 3]
self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ')
self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')]
except:
self.osMinorver = '0'
self.osRevver = '0'
self.osBuild = '0000'
del versionStringStart
del parseLine
del osxcmd
elif sys.platform == 'linux2':
self.osMinorver = '0'
self.osRevver = '0'
self.osBuild = '0000'
开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:32,代码来源:UserFunnel.py
示例8: __init__
def __init__(self, extensions):
'''
This is an initialization function, I do not wish to explain this.
This is a smart way to get the username
We could also have used os.environ, this brings a list and a lot of information we can manipulate.
'''
#
# References: https://en.wikipedia.org/wiki/Environment_variable#Default_values
# https://en.wikipedia.org/wiki/Windows_NT#Releases
#
self.extensions = extensions
if sys.platform == 'win32':
self.desktopdir = path.join(environ['USERPROFILE'], 'Desktop')
# TODO: Set desktopdir to Virtual Directory for testing on Windows too.
# Determine Windows version; check if this is XP; accordingly, read target folders
if not sys.getwindowsversion() == 10:
if sys.getwindowsversion().major < 6:
self.Alldesktopdir = path.join(environ['ALLUSERSPROFILE'], 'Desktop')
else:
self.Alldesktopdir = path.join(environ['PUBLIC'], 'Desktop')
'''list of folders to be created'''
elif sys.platform in ['linux', 'darwin']:
if environ['TEST_DIR'] != '':
self.desktopdir = environ['TEST_DIR']
else:
self.desktopdir = path.join(environ['HOME'], 'Desktop')
else:
print("{} version not implemented".format(sys.platform))
raise NotImplementedError
开发者ID:ssebs,项目名称:OrganiseDesktop,代码行数:32,代码来源:organiseDesktop.py
示例9: ListSids
def ListSids():
sids=[]
# A well know bug in windows version > 8 (major >= 6.2) occurs when a "GetTokenSid" function is called from a 64 bits process. Stop it before its call
win_version = float("%s.%s" % (sys.getwindowsversion()[0], sys.getwindowsversion()[1]))
if "64" in platform.architecture()[0] and win_version > 6.1:
raise OSError("Can't let you to do that because a well known bug is not fixed yet, migrate to a 32 bits process and run this action again.\nEx: run migrate -c \'C:\\Windows\\SysWOW64\\notepad.exe\'")
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'username', 'name'])
except psutil.NoSuchProcess:
pass
if pinfo['pid']<=4:
continue
if pinfo['username'] is None:
continue
try:
hProcess = windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION, False, int(pinfo['pid']))
hToken = HANDLE(INVALID_HANDLE_VALUE)
windll.advapi32.OpenProcessToken(hProcess, tokenprivs, byref(hToken))
try:
sids.append((pinfo['pid'], pinfo['name'], GetTokenSid(hToken), pinfo['username']))
except:
pass
windll.kernel32.CloseHandle(hToken)
windll.kernel32.CloseHandle(hProcess)
except Exception as e:
print e
return list(sids)
开发者ID:AlessandroZ,项目名称:pupy,代码行数:31,代码来源:security.py
示例10: test_getwindowsversion
def test_getwindowsversion(self):
# Raise SkipTest if sys doesn't have getwindowsversion attribute
test.test_support.get_attribute(sys, "getwindowsversion")
v = sys.getwindowsversion()
self.assertEqual(len(v), 5)
self.assertIsInstance(v[0], int)
self.assertIsInstance(v[1], int)
self.assertIsInstance(v[2], int)
self.assertIsInstance(v[3], int)
self.assertIsInstance(v[4], str)
self.assertRaises(IndexError, operator.getitem, v, 5)
self.assertIsInstance(v.major, int)
self.assertIsInstance(v.minor, int)
self.assertIsInstance(v.build, int)
self.assertIsInstance(v.platform, int)
self.assertIsInstance(v.service_pack, str)
self.assertIsInstance(v.service_pack_minor, int)
self.assertIsInstance(v.service_pack_major, int)
self.assertIsInstance(v.suite_mask, int)
self.assertIsInstance(v.product_type, int)
self.assertEqual(v[0], v.major)
self.assertEqual(v[1], v.minor)
self.assertEqual(v[2], v.build)
self.assertEqual(v[3], v.platform)
self.assertEqual(v[4], v.service_pack)
# This is how platform.py calls it. Make sure tuple
# still has 5 elements
maj, min, buildno, plat, csd = sys.getwindowsversion()
开发者ID:plirof,项目名称:minibloq_v0.83,代码行数:29,代码来源:test_sys.py
示例11: configure_logging
def configure_logging(logdir=None, logfile=None, loglevel=LOGLEVEL,
format=LOGFORMAT, filemode=LOGMODE, maxBytes=LOGSIZE,
backupCount=LOGNUM, time_rollover=False):
if logdir is None or logfile is None:
handler = logging.StreamHandler()
elif not time_rollover:
handler = logging.handlers.RotatingFileHandler(
os.path.join(logdir, logfile), maxBytes=maxBytes,
backupCount=backupCount)
else:
handler = logging.handlers.TimedRotatingFileHandler(
os.path.join(logdir, logfile), 'midnight', 1)
# Windows will not allow renaming (or deleting) a file that's open.
# There's nothing the logging package can do about that.
try:
sys.getwindowsversion()
except:
handler.doRollover()
handler.setLevel(loglevel)
formatter = logging.Formatter(format)
handler.setFormatter(formatter)
rootLogger = logging.getLogger()
rootLogger.setLevel(loglevel)
rootLogger.addHandler(handler)
return rootLogger
开发者ID:Daniel-Walther,项目名称:openmicroscopy,代码行数:27,代码来源:__init__.py
示例12: _check_requirements
def _check_requirements(self):
"""
Checks if the GNS3 VM can run on Hyper-V.
"""
if not sys.platform.startswith("win"):
raise GNS3VMError("Hyper-V is only supported on Windows")
if sys.getwindowsversion().platform_version[0] < 10:
raise GNS3VMError("Windows 10/Windows Server 2016 or a later version is required to run Hyper-V with nested virtualization enabled (version {} detected)".format(sys.getwindowsversion().platform_version[0]))
if sys.getwindowsversion().platform_version[0] == 10 and sys.getwindowsversion().platform_version[1] == 0:
if sys.getwindowsversion().platform_version[2] < 14393:
raise GNS3VMError("Hyper-V with nested virtualization is only supported on Windows 10 Anniversary Update (build 10.0.14393) or later")
try:
conn = wmi.WMI()
except wmi.x_wmi as e:
raise GNS3VMError("Could not connect to WMI: {}".format(e))
if not conn.Win32_ComputerSystem()[0].HypervisorPresent:
raise GNS3VMError("Hyper-V is not installed or activated")
if conn.Win32_Processor()[0].Manufacturer != "GenuineIntel":
raise GNS3VMError("An Intel processor is required by Hyper-V to support nested virtualization")
开发者ID:GNS3,项目名称:gns3-server,代码行数:25,代码来源:hyperv_gns3_vm.py
示例13: execute
def execute():
if sys.platform == 'win32':
desktopdir = path.join(environ['USERPROFILE'], 'Desktop')
# Determine Windows version; check if this is XP; accordingly, read target folders
if not sys.getwindowsversion()[0] == 10:
if sys.getwindowsversion().major < 6:
desktopdir = path.join(environ['ALLUSERSPROFILE'], 'Desktop')
else:
desktopdir = path.join(environ['PUBLIC'], 'Desktop')
'''list of folders to be created'''
elif sys.platform == 'linux' or sys.platform == 'darwin':
if environ['TEST_DIR'] != '':
desktopdir = environ['TEST_DIR']
else:
desktopdir = path.join(environ['HOME'], 'Desktop')
else:
print("{} version not implemented".format(sys.platform))
raise NotImplementedError
map1 = listdir(desktopdir)
if sys.platform == 'win32':
separator = '\\'
else:
separator = '/'
for folder in map1:
if folder in Extensions:
contents = listdir(path.join(desktopdir, folder))
for thing in contents:
rename(src=desktopdir+separator+folder+separator+thing, dst=desktopdir+separator+thing)
rmdir(desktopdir+separator+folder)
开发者ID:ssebs,项目名称:OrganiseDesktop,代码行数:32,代码来源:undo.py
示例14: _is_windows
def _is_windows():
"""Returns: True if running on a MS-Windows operating system."""
try:
sys.getwindowsversion()
except:
return False
else:
return True
开发者ID:peterwilliams97,项目名称:git-stats,代码行数:8,代码来源:git_calls.py
示例15: AutoSelect
def AutoSelect():
import platform
if platform.system() == "Linux":
return DBusInhibitor()
elif platform.system() == "Windows" and sys.getwindowsversion().major >= 6 and sys.getwindowsversion().minor >= 1:
return Win7Inhibitor()
else:
raise NotImplementedError("Platform not supported")
开发者ID:euleralencar,项目名称:espresso-python,代码行数:8,代码来源:inhibitors.py
示例16: _set_idle
def _set_idle():
try:
sys.getwindowsversion()
import win32api,win32process,win32con
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS)
except:
os.nice(20)
开发者ID:raqqun,项目名称:PyBitmessage,代码行数:9,代码来源:proofofwork.py
示例17: whatOSver
def whatOSver(self):
if sys.platform == 'win32':
self.osMajorver = str(sys.getwindowsversion()[0])
self.osMinorver = str(sys.getwindowsversion()[1])
self.osBuild = str(sys.getwindowsversion()[2])
self.osType = str(sys.getwindowsversion()[3])
self.osComments = str(sys.getwindowsversion()[4])
return None
if sys.platform == 'darwin':
self.osMajorver = '10'
osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"'
infopipe = os.popen(osxcmd, 'r')
parseLine = infopipe.read()
infopipe.close()
del infopipe
notify.info('parseLine = %s' % str(parseLine))
versionStringStart = parseLine.find('10.')
notify.info('versionStringStart = %s' % str(versionStringStart))
testPlist = False
try:
self.osMinorver = parseLine[versionStringStart + 3]
self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ')
self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')]
except:
notify.info("couldn't parse the system_profiler output, using zeros")
self.osMinorver = '0'
self.osRevver = '0'
self.osBuild = '0000'
testPlist = True
del versionStringStart
del parseLine
del osxcmd
if testPlist:
try:
import plistlib as plistlib
pl = plistlib.readPlist('/System/Library/CoreServices/SystemVersion.plist')
notify.info('pl=%s' % str(pl))
parseLine = pl['ProductVersion']
numbers = parseLine.split('.')
notify.info('parseline =%s numbers =%s' % (parseLine, numbers))
self.osMinorver = numbers[1]
self.osRevver = numbers[2]
self.osBuild = pl['ProductBuildVersion']
except:
notify.info('tried plist but still got exception')
self.osMinorver = '0'
self.osRevver = '0'
self.osBuild = '0000'
return None
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:55,代码来源:UserFunnel.py
示例18: _set_idle
def _set_idle():
if 'linux' in sys.platform:
os.nice(20)
else:
try:
sys.getwindowsversion()
import win32api,win32process,win32con # @UnresolvedImport
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS)
except:
#Windows 64-bit
pass
开发者ID:Bitmessage,项目名称:PyBitmessage,代码行数:13,代码来源:proofofwork.py
示例19: getpolicyid
def getpolicyid(self, fuzzy=True, language=None, windowsversion=None):
"""
Return an identification string which can be used to find a policy.
This string is a combination of the manifest's processorArchitecture,
major and minor version, name, publicKeyToken and language.
Arguments:
fuzzy (boolean) - If False, insert the full version in
the id string. Default is True (omit).
windowsversion - If not specified (or None), default to
(tuple or list of integers) sys.getwindowsversion().
"""
if not self.name:
if not silent:
print "W: Assembly metadata incomplete"
return ""
id = []
if self.processorArchitecture:
id.append(self.processorArchitecture)
name = []
name.append("policy")
if self.version:
name.append(str(self.version[0]))
name.append(str(self.version[1]))
name.append(self.name)
id.append(".".join(name))
if self.publicKeyToken:
id.append(self.publicKeyToken)
if self.version and (windowsversion or sys.getwindowsversion()) >= (6, ):
# Vista and later
if fuzzy:
id.append("*")
else:
id.append(".".join([str(i) for i in self.version]))
if not language:
language = self.getlanguage(windowsversion=windowsversion)
if language:
id.append(language)
id.append("*")
id = "_".join(id)
if self.version and (windowsversion or sys.getwindowsversion()) < (6, ):
# Windows XP
if fuzzy:
id = os.path.join(id, "*")
else:
id = os.path.join(id, ".".join([str(i) for i in self.version]))
return id
开发者ID:C4rt,项目名称:pyinstaller,代码行数:49,代码来源:winmanifest.py
示例20: getWindowsVersion
def getWindowsVersion():
""" Возвращаем версию ОС Windows
Возвращает:
(string) версия ОС Windows:
...
4.0 - Windows NT 4.0
5.0 - Windows 2000
5.1 - Windows XP
5.2 - Windows Server 2003
6.0 - Windows Vista
6.1 - Windows 7, Windows Server 2008 R2,
6.2 - Windows 8
"""
return "%s.%s" % (sys.getwindowsversion().major, sys.getwindowsversion().minor)
开发者ID:kirsrus,项目名称:ArchiveAnalizer,代码行数:15,代码来源:kssys.py
注:本文中的sys.getwindowsversion函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论