本文整理汇总了Python中win32api.error方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.error方法的具体用法?Python win32api.error怎么用?Python win32api.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def send(self, channel_type, message, additional_data):
if channel_type == common.CONTROL_CHANNEL_BYTE:
transformed_message = self.transform(self.encryption, common.CONTROL_CHANNEL_BYTE+message, 1)
else:
transformed_message = self.transform(self.encryption, common.DATA_CHANNEL_BYTE+message, 1)
common.internal_print("{0} sent: {1}".format(self.module_short, len(transformed_message)), 0, self.verbosity, common.DEBUG)
# WORKAROUND?!
# Windows: It looks like when the buffer fills up the OS does not do
# congestion control, instead throws and exception/returns with
# WSAEWOULDBLOCK which means that we need to try it again later.
# So we sleep 100ms and hope that the buffer has more space for us.
# If it does then it sends the data, otherwise tries it in an infinite
# loop...
while True:
try:
return self.comms_socket.send(struct.pack(">H", len(transformed_message))+transformed_message)
except socket.error as se:
if se.args[0] == 10035: # WSAEWOULDBLOCK
time.sleep(0.1)
pass
else:
raise
示例2: check
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def check(self):
try:
common.internal_print("Checking module on server: {0}".format(self.get_module_name()))
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.settimeout(3)
server_socket.connect((self.config.get("Global", "remoteserverip"), int(self.config.get(self.get_module_configname(), "serverport"))))
client_fake_thread = TCP_generic_thread(0, 0, None, None, server_socket, None, self.authentication, self.encryption_module, self.verbosity, self.config, self.get_module_name())
client_fake_thread.do_check()
client_fake_thread.communication(True)
self.cleanup(server_socket)
except socket.timeout:
common.internal_print("Checking failed: {0}".format(self.get_module_name()), -1)
self.cleanup(server_socket)
except socket.error as exception:
if exception.args[0] == 111:
common.internal_print("Checking failed: {0}".format(self.get_module_name()), -1)
else:
common.internal_print("Connection error: {0}".format(self.get_module_name()), -1)
self.cleanup(server_socket)
return
示例3: connect
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def connect(self):
try:
common.internal_print("Starting client: {0}".format(self.get_module_name()))
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.server_tuple = (self.config.get("Global", "remoteserverip"), int(self.config.get(self.get_module_configname(), "serverport")))
self.comms_socket = server_socket
self.serverorclient = 0
self.authenticated = False
self.do_hello()
self.communication(False)
except KeyboardInterrupt:
self.do_logoff()
self.cleanup()
raise
except socket.error:
self.cleanup()
raise
self.cleanup()
return
示例4: check
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def check(self):
try:
common.internal_print("Checking module on server: {0}".format(self.get_module_name()))
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.server_tuple = (self.config.get("Global", "remoteserverip"), int(self.config.get(self.get_module_configname(), "serverport")))
self.comms_socket = server_socket
self.serverorclient = 0
self.authenticated = False
self.do_check()
self.communication(True)
except KeyboardInterrupt:
self.cleanup()
raise
except socket.timeout:
common.internal_print("Checking failed: {0}".format(self.get_module_name()), -1)
except socket.error:
self.cleanup()
raise
self.cleanup()
return
示例5: CheckLoaderModule
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def CheckLoaderModule(dll_name):
suffix = ""
if is_debug_build: suffix = "_d"
template = os.path.join(this_dir,
"PyISAPI_loader" + suffix + ".dll")
if not os.path.isfile(template):
raise ConfigurationError(
"Template loader '%s' does not exist" % (template,))
# We can't do a simple "is newer" check, as the DLL is specific to the
# Python version. So we check the date-time and size are identical,
# and skip the copy in that case.
src_stat = os.stat(template)
try:
dest_stat = os.stat(dll_name)
except os.error:
same = 0
else:
same = src_stat[stat.ST_SIZE]==dest_stat[stat.ST_SIZE] and \
src_stat[stat.ST_MTIME]==dest_stat[stat.ST_MTIME]
if not same:
log(2, "Updating %s->%s" % (template, dll_name))
shutil.copyfile(template, dll_name)
shutil.copystat(template, dll_name)
else:
log(2, "%s is up to date." % (dll_name,))
示例6: JobError
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def JobError(self, job, error):
print 'Job Error', job, error
f = error.GetFile()
print 'While downloading', f.GetRemoteName()
print 'To', f.GetLocalName()
print 'The following error happened:'
self._print_error(error)
if f.GetRemoteName().endswith('missing-favicon.ico'):
print 'Changing to point to correct file'
f2 = f.QueryInterface(bits.IID_IBackgroundCopyFile2)
favicon = 'http://www.python.org/favicon.ico'
print 'Changing RemoteName from', f2.GetRemoteName(), 'to', favicon
f2.SetRemoteName(favicon)
job.Resume()
else:
job.Cancel()
示例7: _CreateMainWindow
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def _CreateMainWindow(self, prev, settings, browser, rect):
# Creates a parent window that hosts the view window. This window
# gets the control notifications etc sent from the child.
style = win32con.WS_CHILD | win32con.WS_VISIBLE #
wclass_name = "ShellViewDemo_DefView"
# Register the Window class.
wc = win32gui.WNDCLASS()
wc.hInstance = win32gui.dllhandle
wc.lpszClassName = wclass_name
wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
try:
win32gui.RegisterClass(wc)
except win32gui.error, details:
# Should only happen when this module is reloaded
if details[0] != winerror.ERROR_CLASS_ALREADY_EXISTS:
raise
示例8: GetName
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def GetName(self, dnt):
name = self.module.__name__
try:
fname = win32api.GetFullPathName(self.module.__file__)
except win32api.error:
fname = self.module.__file__
except AttributeError:
fname = name
if dnt==axdebug.DOCUMENTNAMETYPE_APPNODE:
return name.split(".")[-1]
elif dnt==axdebug.DOCUMENTNAMETYPE_TITLE:
return fname
elif dnt==axdebug.DOCUMENTNAMETYPE_FILE_TAIL:
return os.path.split(fname)[1]
elif dnt==axdebug.DOCUMENTNAMETYPE_URL:
return "file:%s" % fname
else:
raise Exception(scode=winerror.E_UNEXPECTED)
示例9: GetSubList
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def GetSubList(self):
keyStr = regutil.BuildDefaultPythonKey() + "\\PythonPath"
hKey = win32api.RegOpenKey(regutil.GetRootKey(), keyStr)
try:
ret = []
ret.append(HLIProjectRoot("", "Standard Python Library")) # The core path.
index = 0
while 1:
try:
ret.append(HLIProjectRoot(win32api.RegEnumKey(hKey, index)))
index = index + 1
except win32api.error:
break
return ret
finally:
win32api.RegCloseKey(hKey)
示例10: UpdateForRegItem
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def UpdateForRegItem(self, item):
self.DeleteAllItems()
hkey = win32api.RegOpenKey(item.keyRoot, item.keyName)
try:
valNum = 0
ret = []
while 1:
try:
res = win32api.RegEnumValue(hkey, valNum)
except win32api.error:
break
name = res[0]
if not name: name = "(Default)"
self.InsertItem(valNum, name)
self.SetItemText(valNum, 1, str(res[1]))
valNum = valNum + 1
finally:
win32api.RegCloseKey(hkey)
示例11: GetSubList
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def GetSubList(self):
hkey = win32api.RegOpenKey(self.keyRoot, self.keyName)
win32ui.DoWaitCursor(1)
try:
keyNum = 0
ret = []
while 1:
try:
key = win32api.RegEnumKey(hkey, keyNum)
except win32api.error:
break
ret.append(HLIRegistryKey(self.keyRoot, self.keyName + "\\" + key, key))
keyNum = keyNum + 1
finally:
win32api.RegCloseKey(hkey)
win32ui.DoWaitCursor(0)
return ret
示例12: OnUpdatePosIndicator
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def OnUpdatePosIndicator(self, cmdui):
editControl = scriptutils.GetActiveEditControl()
value = " " * 5
if editControl is not None:
try:
startChar, endChar = editControl.GetSel()
lineNo = editControl.LineFromChar(startChar)
colNo = endChar - editControl.LineIndex(lineNo)
if cmdui.m_nID==win32ui.ID_INDICATOR_LINENUM:
value = "%0*d" % (5, lineNo + 1)
else:
value = "%0*d" % (3, colNo + 1)
except win32ui.error:
pass
cmdui.SetText(value)
cmdui.Enable()
示例13: OnHelp
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def OnHelp(self,id, code):
try:
if id==win32ui.ID_HELP_GUI_REF:
helpFile = regutil.GetRegisteredHelpFile("Pythonwin Reference")
helpCmd = win32con.HELP_CONTENTS
else:
helpFile = regutil.GetRegisteredHelpFile("Main Python Documentation")
helpCmd = win32con.HELP_FINDER
if helpFile is None:
win32ui.MessageBox("The help file is not registered!")
else:
import help
help.OpenHelpFile(helpFile, helpCmd)
except:
t, v, tb = sys.exc_info()
win32ui.MessageBox("Internal error in help file processing\r\n%s: %s" % (t,v))
tb = None # Prevent a cycle
示例14: _HandlePythonFailure
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def _HandlePythonFailure(what, syntaxErrorPathName = None):
typ, details, tb = sys.exc_info()
if isinstance(details, SyntaxError):
try:
msg, (fileName, line, col, text) = details
if (not fileName or fileName =="<string>") and syntaxErrorPathName:
fileName = syntaxErrorPathName
_JumpToPosition(fileName, line, col)
except (TypeError, ValueError):
msg = str(details)
win32ui.SetStatusText('Failed to ' + what + ' - syntax error - %s' % msg)
else:
traceback.print_exc()
win32ui.SetStatusText('Failed to ' + what + ' - ' + str(details) )
tb = None # Clean up a cycle.
# Find the Python TabNanny in either the standard library or the Python Tools/Scripts directory.
示例15: HandleSpecialLine
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import error [as 别名]
def HandleSpecialLine(self):
import scriptutils
line = self.GetLine()
if line[:11]=="com_error: ":
# An OLE Exception - pull apart the exception
# and try and locate a help file.
try:
import win32api, win32con
det = eval(line[line.find(":")+1:].strip())
win32ui.SetStatusText("Opening help file on OLE error...");
import help
help.OpenHelpFile(det[2][3],win32con.HELP_CONTEXT, det[2][4])
return 1
except win32api.error, details:
win32ui.SetStatusText("The help file could not be opened - %s" % details.strerror)
return 1
except: