當前位置: 首頁>>代碼示例>>Python>>正文


Python sys.winver方法代碼示例

本文整理匯總了Python中sys.winver方法的典型用法代碼示例。如果您正苦於以下問題:Python sys.winver方法的具體用法?Python sys.winver怎麽用?Python sys.winver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sys的用法示例。


在下文中一共展示了sys.winver方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: InitInstance

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def InitInstance(self):
		# Use a registry path of "Python\Pythonwin Debugger
		win32ui.SetAppName(win32ui.LoadString(win32ui.IDR_DEBUGGER))
		win32ui.SetRegistryKey("Python %s" % (sys.winver,))
		# We _need_ the Scintilla color editor.
		# (and we _always_ get it now :-)

		numMRU = win32ui.GetProfileVal("Settings","Recent File List Size", 10)
		win32ui.LoadStdProfileSettings(numMRU)

		self.LoadMainFrame()

		# Display the interactive window if the user wants it.
		from pywin.framework import interact
		interact.CreateInteractiveWindowUserPreference()

		# Load the modules we use internally.
		self.LoadSystemModules()
		# Load additional module the user may want.
		self.LoadUserModules()

#		win32ui.CreateDebuggerThread()
		win32ui.EnableControlContainer() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:25,代碼來源:dbgpyapp.py

示例2: RegisterCoreDLL

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def RegisterCoreDLL(coredllName = None):
	"""Registers the core DLL in the registry.

        If no params are passed, the name of the Python DLL used in 
        the current process is used and registered.
	"""
	if coredllName is None:
		coredllName = win32api.GetModuleFileName(sys.dllhandle)
		# must exist!
	else:
		try:
			os.stat(coredllName)
		except os.error:
			print "Warning: Registering non-existant core DLL %s" % coredllName

	hKey = win32api.RegCreateKey(GetRootKey() , BuildDefaultPythonKey())
	try:
		win32api.RegSetValue(hKey, "Dll", win32con.REG_SZ, coredllName)
	finally:
		win32api.RegCloseKey(hKey)
	# Lastly, setup the current version to point to me.
	win32api.RegSetValue(GetRootKey(), "Software\\Python\\PythonCore\\CurrentVersion", win32con.REG_SZ, sys.winver) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:regutil.py

示例3: test_bad_stuff

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def test_bad_stuff():
    '''
    Cases where IP should not load an assembly for one
    reason or another.
    '''
    
    #ensure that users cannot override IP native modules
    import sys
    Assert(sys.winver != "HIJACKED")
    import re
    Assert(re.compile != "HIJACKED")

    #ensure corrupted DLLs cannot be loaded
    try:
        import fooCORRUPT
        raise Exception("Corrupted DLL was loaded")
    except ImportError, e:
        pass
    
    #nothing to do for unmanaged DLLs...if the interpreter has made it
    #this far, all is well:)
    
    
    #ensure *.exe's cannot take precedence over *.dlls 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:26,代碼來源:dllsite.py

示例4: FindTabNanny

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def FindTabNanny():
	try:
		return __import__("tabnanny")
	except ImportError:
		pass
	# OK - not in the standard library - go looking.
	filename = "tabnanny.py"
	try:
		path = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\Python\\PythonCore\\%s\\InstallPath" % (sys.winver))
	except win32api.error:
		print "WARNING - The Python registry does not have an 'InstallPath' setting"
		print "          The file '%s' can not be located" % (filename)
		return None
	fname = os.path.join(path, "Tools\\Scripts\\%s" % filename)
	try:
		os.stat(fname)
	except os.error:
		print "WARNING - The file '%s' can not be located in path '%s'" % (filename, path)
		return None

	tabnannyhome, tabnannybase = os.path.split(fname)
	tabnannybase = os.path.splitext(tabnannybase)[0]
	# Put tab nanny at the top of the path.
	sys.path.insert(0, tabnannyhome)
	try:
		return __import__(tabnannybase)
	finally:
		# remove the tab-nanny from the path
		del sys.path[0] 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:31,代碼來源:scriptutils.py

示例5: InitInstance

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def InitInstance(self):
		# Allow "/nodde" and "/newinstance to optimize this!
		if "/nodde" not in sys.argv and "/newinstance" not in sys.argv:
			if self.InitDDE():
				return 1 # A remote DDE client is doing it for us!
		else:
			self.ddeServer = None

		win32ui.SetRegistryKey("Python %s" % (sys.winver,)) # MFC automatically puts the main frame caption on!
		app.CApp.InitInstance(self)

		# Create the taskbar icon
		win32ui.CreateDebuggerThread()

		# Allow Pythonwin to host OCX controls.
		win32ui.EnableControlContainer()

		# Display the interactive window if the user wants it.
		import interact
		interact.CreateInteractiveWindowUserPreference()

		# Load the modules we use internally.
		self.LoadSystemModules()

		# Load additional module the user may want.
		self.LoadUserModules()

		# Load the ToolBar state near the end of the init process, as
		# there may be Toolbar IDs created by the user or other modules.
		# By now all these modules should be loaded, so all the toolbar IDs loaded.
		try:
			self.frame.LoadBarState("ToolbarDefault")
		except win32ui.error:
			# MFC sucks.  It does essentially "GetDlgItem(x)->Something", so if the
			# toolbar with ID x does not exist, MFC crashes!  Pythonwin has a trap for this
			# but I need to investigate more how to prevent it (AFAIK, ensuring all the
			# toolbars are created by now _should_ stop it!)
			pass

		# Finally process the command line arguments.
		self.ProcessArgs(sys.argv) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:43,代碼來源:intpyapp.py

示例6: DumpPythonRegistry

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def DumpPythonRegistry():
    try:
        h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\PythonPath" % sys.winver)
    except win32api.error:
        print "The remote device does not appear to have Python installed"
        return 0
    path, typ = wincerapi.CeRegQueryValueEx(h, None)
    print "The remote PythonPath is '%s'" % (str(path), )
    h.Close()
    return 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:cerapi.py

示例7: _doregister

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def _doregister(mod_name, dll_name):
    assert os.path.isfile(dll_name), "Shouldn't get here if the file doesn't exist!"
    try:
        key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
    except _winreg.error:
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
        except _winreg.error:
            print "Could not find the existing '%s' module registered in the registry" % (mod_name,)
            usage_and_die(4)
    # Create the debug key.
    sub_key = _winreg.CreateKey(key, "Debug")
    _winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
    print "Registered '%s' in the registry" % (dll_name,) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:setup_d.py

示例8: _find_localserver_exe

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def _find_localserver_exe(mustfind):
  if not sys.platform.startswith("win32"):
    return sys.executable
  if pythoncom.__file__.find("_d") < 0:
    exeBaseName = "pythonw.exe"
  else:
    exeBaseName = "pythonw_d.exe"
  # First see if in the same directory as this .EXE
  exeName = os.path.join( os.path.split(sys.executable)[0], exeBaseName )
  if not os.path.exists(exeName):
    # See if in our sys.prefix directory
    exeName = os.path.join( sys.prefix, exeBaseName )
  if not os.path.exists(exeName):
    # See if in our sys.prefix/pcbuild directory (for developers)
    if "64 bit" in sys.version:
      exeName = os.path.join( sys.prefix, "PCbuild",  "amd64", exeBaseName )
    else:
      exeName = os.path.join( sys.prefix, "PCbuild",  exeBaseName )
  if not os.path.exists(exeName):
    # See if the registry has some info.
    try:
      key = "SOFTWARE\\Python\\PythonCore\\%s\\InstallPath" % sys.winver
      path = win32api.RegQueryValue( win32con.HKEY_LOCAL_MACHINE, key )
      exeName = os.path.join( path, exeBaseName )
    except (AttributeError,win32api.error):
      pass
  if not os.path.exists(exeName):
    if mustfind:
      raise RuntimeError("Can not locate the program '%s'" % exeBaseName)
    return None
  return exeName 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:33,代碼來源:register.py

示例9: gen_bug_report

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def gen_bug_report(mod_name, diffs, outdir):
    needs_to_be_implemented = collect_diffs(diffs, '-')
    needs_to_be_removed = collect_diffs(diffs, '+')
    
    if not needs_to_be_implemented and not needs_to_be_removed:
        return
    
    bug_report_name = outdir + "\\%s.log" % mod_name
    bug_report = open(bug_report_name, "w")
    bug_report.write(BUG_REPORT_PRE % (mod_name, str(sys.winver)))

    #--unfiltered list of attributes to be added
    if len(needs_to_be_implemented)>0:
        bug_report.write("-------------------------------------------------------\n")
        bug_report.write("""Complete list of module attributes IronPython is still 
missing implementations for:
""")
        for x in needs_to_be_implemented:
            bug_report.write("    " + x + '\n')
        bug_report.write("\n\n\n")
    
    #--unfiltered list of attributes to be removed
    if len(needs_to_be_removed)>0:
        bug_report.write("-------------------------------------------------------\n")
        bug_report.write("""Complete list of module attributes that should be removed 
from IronPython:
""")
        for x in needs_to_be_removed:
            bug_report.write("    " + x + '\n')
    
    bug_report.close()
    return bug_report_name 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:34,代碼來源:modulediff.py

示例10: _get_lib_path

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def _get_lib_path():
    if os.name == 'nt':
        if 'PyPy' in sys.version:
            return os.path.join(sys.prefix, 'lib-python', sys.winver)
        else:
            return os.path.join(sys.prefix, 'Lib')
    else:
        return [x for x in sys.path if x.endswith('%s.%s' % sys.version_info[:2])][0] 
開發者ID:lark-parser,項目名稱:lark,代碼行數:10,代碼來源:python_parser.py

示例11: test_winver

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def test_winver(self):
        import re
        #E.g., "2.5"
        self.assertTrue(re.match("^\d\.\d$", sys.winver) != None) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:6,代碼來源:test_sys.py

示例12: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def __init__(self):
        self.path = "WindowsRegistry"
        self.map = {}
        try:
            import win32api
            import win32con
        except ImportError:
            return

        subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
        for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE):
            try:
                hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ)
            except Exception, e:
                logger.debug('RegistryImportDirector: %s' % e)
                continue

            numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
            for i in range(numsubkeys):
                subkeyname = win32api.RegEnumKey(hkey, i)
                hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ)
                val = win32api.RegQueryValueEx(hskey, '')
                desc = getDescr(val[0])
                #print " RegistryImportDirector got %s %s" % (val[0], desc)  #XXX
                self.map[subkeyname] = (val[0], desc)
                hskey.Close()
            hkey.Close()
            break 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:30,代碼來源:impdirector.py

示例13: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def __init__(self):
        self.path = "WindowsRegistry"
        self.map = {}
        try:
            import win32api
            ## import win32con
        except ImportError:
            pass
        else:
            HKEY_CURRENT_USER = -2147483647
            HKEY_LOCAL_MACHINE = -2147483646
            KEY_ALL_ACCESS = 983103
            subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
            for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE):
                try:
                    hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_ALL_ACCESS)
                except:
                    pass
                else:
                    numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
                    for i in range(numsubkeys):
                        subkeyname = win32api.RegEnumKey(hkey, i)
                        hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_ALL_ACCESS)
                        val = win32api.RegQueryValueEx(hskey, '')
                        desc = getDescr(val[0])
                        self.map[subkeyname] = (val[0], desc)
                        hskey.Close()
                    hkey.Close()
                    break 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:31,代碼來源:ImportManager.py

示例14: SetupEnvironment

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def SetupEnvironment():
	HKEY_LOCAL_MACHINE = -2147483646 # Avoid pulling in win32con for just these...
	KEY_QUERY_VALUE = 0x1
	# Open the root key once, as this is quite slow on NT.
	try:
		keyName = "SOFTWARE\\Python\\PythonCore\\%s\\PythonPath\\win32com" % sys.winver
		key = win32api.RegOpenKey(HKEY_LOCAL_MACHINE , keyName, 0, KEY_QUERY_VALUE)
	except (win32api.error, AttributeError):
		key = None
		
	try:
		found = 0
		if key is not None:
			try:
				__path__.append( win32api.RegQueryValue(key, "Extensions" ))
				found = 1
			except win32api.error:
				# Nothing registered
				pass
		if not found:
			try:
				__path__.append( win32api.GetFullPathName( __path__[0] + "\\..\\win32comext") )
			except win32api.error:
				# Give up in disgust!
				pass
	
		# For the sake of developers, we also look up a "BuildPath" key
		# If extension modules add support, we can load their .pyd's from a completely
		# different directory (see the comments below)
		try:
			if key is not None:
				global __build_path__
				__build_path__ = win32api.RegQueryValue(key, "BuildPath")
				__path__.append(__build_path__)
		except win32api.error:
			# __build_path__ neednt be defined.
			pass
		global __gen_path__
		if key is not None:
			try:
				__gen_path__ = win32api.RegQueryValue(key, "GenPath")
			except win32api.error:
				pass
	finally:
		if key is not None:
			key.Close()

# A Helper for developers.  A sub-package's __init__ can call this help function,
# which allows the .pyd files for the extension to live in a special "Build" directory
# (which the win32com developers do!) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:52,代碼來源:__init__.py

示例15: gen_bug_report

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import winver [as 別名]
def gen_bug_report(mod_name, needs_to_be_implemented, needs_to_be_removed):
    bug_report_name = "bug_reports\\%s.log" % mod_name
    bug_report = open(bug_report_name, "w")
    bug_report.write(BUG_REPORT_PRE % (mod_name, str(sys.winver)))
    
    bug_report.write("-------------------------------------------------------\n")
    bug_report.write("""After filtering out Python special method names, 
IronPython is still MISSING implementations for the 
following module attributes:
""")
    for x in needs_to_be_implemented:
        if re.search(REGEX_FILTER, x)==None:
            bug_report.write("    " + x)
    bug_report.write("\n\n")
    
    bug_report.write("-------------------------------------------------------\n")
    bug_report.write("""After filtering out Python special method names, 
IronPython is still PROVIDING implementations for the 
following module attributes which should NOT exist:
""")
    for x in needs_to_be_removed:
        if re.search(REGEX_FILTER, x)==None:
            bug_report.write("    " + x)
    bug_report.write("\n\n")
    
    #--unfiltered list of attributes to be added
    if len(needs_to_be_implemented)>0:
        bug_report.write("-------------------------------------------------------\n")
        bug_report.write("""Complete list of module attributes IronPython is still 
missing implementations for:
""")
        for x in needs_to_be_implemented:
            bug_report.write("    " + x)
        bug_report.write("\n\n\n")
    
    #--unfiltered list of attributes to be removed
    if len(needs_to_be_removed)>0:
        bug_report.write("-------------------------------------------------------\n")
        bug_report.write("""Complete list of module attributes that should be removed 
from IronPython:
""")
        for x in needs_to_be_removed:
            bug_report.write("    " + x)
    
    bug_report.close()
    return bug_report_name
    


#--MAIN------------------------------------------------------------------------ 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:52,代碼來源:cmodule.py


注:本文中的sys.winver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。