本文整理汇总了Python中errno.ENOEXEC属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ENOEXEC属性的具体用法?Python errno.ENOEXEC怎么用?Python errno.ENOEXEC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类errno
的用法示例。
在下文中一共展示了errno.ENOEXEC属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_test
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def test_test(self, Popen):
handler = reactive.bus.ExternalHandler('filepath')
Popen.return_value.communicate.return_value = ('output', None)
Popen.return_value.returncode = 0
assert handler.test()
Popen.return_value.returncode = 1
assert not handler.test()
Popen.assert_called_with(['filepath', '--test'], stdout=reactive.bus.subprocess.PIPE, env='env')
e = Popen.side_effect = OSError()
e.errno = errno.ENOEXEC
self.assertRaises(reactive.bus.BrokenHandlerException, handler.test)
e.errno = errno.ENOENT
self.assertRaises(OSError, handler.test)
示例2: _RunAdbCmd
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None,
check_error=True, cpu_affinity=None,
ensure_logs_on_timeout=False):
timeout = timeout_retry.CurrentTimeoutThreadGroup().GetRemainingTime()
if ensure_logs_on_timeout:
timeout = 0.95 * timeout
try:
status, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
cls._BuildAdbCmd(args, device_serial, cpu_affinity=cpu_affinity),
timeout, env=cls._ADB_ENV)
except OSError as e:
if e.errno in (errno.ENOENT, errno.ENOEXEC):
raise device_errors.NoAdbError(msg=str(e))
else:
raise
# Best effort to catch errors from adb; unfortunately adb is very
# inconsistent with error reporting so many command failures present
# differently.
if status != 0 or (check_error and output.startswith('error:')):
not_found_m = _DEVICE_NOT_FOUND_RE.match(output)
device_waiting_m = _WAITING_FOR_DEVICE_RE.match(output)
if (device_waiting_m is not None
or (not_found_m is not None and
not_found_m.group('serial') == device_serial)):
raise device_errors.DeviceUnreachableError(device_serial)
else:
raise device_errors.AdbCommandFailedError(
args, output, status, device_serial)
return output
# pylint: enable=unused-argument
示例3: test
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def test(self):
"""
Call the external handler to test whether it should be invoked.
"""
# flush to ensure external process can see flags as they currently
# are, and write flags (flush releases lock)
unitdata.kv().flush()
try:
proc = subprocess.Popen([self._filepath, '--test'], stdout=subprocess.PIPE, env=os.environ)
except OSError as oserr:
if oserr.errno == errno.ENOEXEC:
raise BrokenHandlerException(self._filepath)
raise
self._test_output, _ = proc.communicate()
return proc.returncode == 0
示例4: testUnresolvedAddress
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def testUnresolvedAddress(self):
try:
self.s.connect( ('non.existent.server', PORT) )
except socket.gaierror, gaix:
self.failUnlessEqual(gaix[0], errno.ENOEXEC)
示例5: start
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def start(self, builddir, program, forward_args):
''' Launch the specified program. Uses the `start` script if specified
by the target, attempts to run it natively if that script is not
defined.
'''
child = None
try:
prog_path = self.findProgram(builddir, program)
if prog_path is None:
return
start_env, start_vars = self.buildProgEnvAndVars(prog_path, builddir)
if self.getScript('start'):
cmd = [
os.path.expandvars(string.Template(x).safe_substitute(**start_vars))
for x in self.getScript('start')
] + forward_args
else:
cmd = shlex.split('./' + prog_path) + forward_args
logger.debug('starting program: %s', cmd)
child = subprocess.Popen(
cmd, cwd = builddir, env = start_env
)
child.wait()
if child.returncode:
return "process exited with status %s" % child.returncode
child = None
except OSError as e:
import errno
if e.errno == errno.ENOEXEC:
return ("the program %s cannot be run (perhaps your target "+
"needs to define a 'start' script to start it on its "
"intended execution target?)") % prog_path
finally:
if child is not None:
_tryTerminate(child)
示例6: _construct_file
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def _construct_file(setup_cfg, setup, fmt, start):
if not os.path.isfile(setup) or not os.access(setup, os.R_OK):
print(setup + " does not exist or is not readable")
exit_cleanly(error_number=errno.ENOSYS)
contents = _read_in_cfgs(setup_cfg)
parsed_reqs = map(lambda x: (x.req), p_reqs(setup, session="pkg"))
if not parsed_reqs:
print("Nothing to do!\n%s\nDoes not contain any reqs parsable!" %
setup)
exit_cleanly(error_number=0)
try:
base_dir = os.path.dirname(setup_cfg)
if not os.path.isdir(base_dir):
try:
os.mkdir(base_dir)
except OSError as Error:
if Error.errno != errno.EEXIST:
raise
with open(setup_cfg, 'w') as fh:
pkg_type = ''
if contents:
while contents:
fh.write(contents.popleft())
fh.write(start)
for count in range(len(parsed_reqs)):
req = parsed_reqs[count]
if 'Depends' in start:
# special case for debian...
name = str(req.name) if 'python-' in str(req.name) else \
'python-' + str(req.name)
pkg_type = 'deb'
else:
name = str(req.name)
pkg_type = 'rpm'
specifier = str(req.specifier)
if '==' in specifier:
handle_equals(fh, fmt, name, specifier, pkg_type=pkg_type)
continue
else:
relation_oper = re.compile('([><=]{1,2})(.*)')
match = relation_oper.search(specifier)
if match:
specifier = ' '.join(match.groups())
else:
print("Error: the format of dependencies can not be parsed")
exit_cleanly(error_number=errno.ENOEXEC)
fh.write(fmt % (name, specifier))
if count != len(parsed_reqs) - 1:
fh.write('\n ')
fh.write("\n") # some packages require a new line
except AssertionError as Error:
raise ValueError(str(Error))
except IOError as Error:
print(Error)
exit_cleanly(error_number=errno.EIO)
示例7: getaddrinfo
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOEXEC [as 别名]
def getaddrinfo(host, port, family=AF_UNSPEC, socktype=0, proto=0, flags=0):
if family is None:
family = AF_UNSPEC
if socktype is None:
socktype = 0
if not family in [AF_INET, AF_INET6, AF_UNSPEC]:
raise gaierror(errno.EIO, 'ai_family not supported')
host = _getaddrinfo_get_host(host, family, flags)
port = _getaddrinfo_get_port(port, flags)
if socktype not in [0, SOCK_DGRAM, SOCK_STREAM]:
raise error(errno.ESOCKTNOSUPPORT, "Socket type is not supported")
filter_fns = []
filter_fns.append({
AF_INET: lambda x: isinstance(x, java.net.Inet4Address),
AF_INET6: lambda x: isinstance(x, java.net.Inet6Address),
AF_UNSPEC: lambda x: isinstance(x, java.net.InetAddress),
}[family])
if host in [None, ""]:
if flags & AI_PASSIVE:
hosts = {AF_INET: [INADDR_ANY], AF_INET6: [IN6ADDR_ANY_INIT], AF_UNSPEC: [INADDR_ANY, IN6ADDR_ANY_INIT]}[family]
else:
hosts = ["localhost"]
else:
hosts = [host]
results = []
for h in hosts:
try:
all_by_name = java.net.InetAddress.getAllByName(h)
except java.net.UnknownHostException:
raise gaierror(errno.ENOEXEC, 'nodename nor servname provided, or not known')
for a in all_by_name:
if len([f for f in filter_fns if f(a)]):
family = {java.net.Inet4Address: AF_INET, java.net.Inet6Address: AF_INET6}[a.getClass()]
if flags & AI_CANONNAME:
canonname = str(a.getCanonicalHostName())
else:
canonname = ""
sockaddr = str(a.getHostAddress())
# TODO: Include flowinfo and scopeid in a 4-tuple for IPv6 addresses
sock_tuple = {AF_INET : _ipv4_address_t, AF_INET6 : _ipv6_address_t}[family](sockaddr, port, a)
if socktype == 0:
socktypes = [SOCK_DGRAM, SOCK_STREAM]
else:
socktypes = [socktype]
for result_socktype in socktypes:
result_proto = {SOCK_DGRAM: IPPROTO_UDP, SOCK_STREAM: IPPROTO_TCP}[result_socktype]
if proto in [0, result_proto]:
# The returned socket will only support the result_proto
# If this does not match the requested proto, don't return it
results.append((family, result_socktype, result_proto, canonname, sock_tuple))
return results