本文整理汇总了Python中twisted.python.runtime.platform.isWindows函数的典型用法代码示例。如果您正苦于以下问题:Python isWindows函数的具体用法?Python isWindows怎么用?Python isWindows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isWindows函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, server_key, config):
self._subtype = config["subtype"].lower()
self._server_key = server_key
self._config = config
#setup logging
self.logdata = []
self.lastlogtime = time.time()
self.loggingport = 0
self._dediids = {'tf': 232250, 'dod': 232290, 'css': 232330}
#setup rcon
self.rcon = SourceRcon.SourceRcon(self._config["ip"], int(self._config["port"]), self._config["rcon_password"])
if self._subtype == "":
self._subtype = None
log.debug("server_key:", server_key, "self._subtype:", self._subtype)
if self._subtype is None:
if platform.isWindows():
self._server = SRCDSServerProcessWin32(server_key, config)
else:
self._server = SRCDSServerBase(server_key, config)
elif self._subtype == "svc":
if platform.isWindows():
self._server = SRCDSServerServiceWin32(server_key, config)
else:
self._server = SRCDSServerBase(server_key, config)
elif self._subtype == "gs":
self._server = SRCDSServerGS(server_key, config)
开发者ID:gamingrobot,项目名称:SCI,代码行数:33,代码来源:srcds.py
示例2: setUp
def setUp(self):
"""
Clear the SIGCHLD handler, if there is one, to ensure an environment
like the one which exists prior to a call to L{reactor.run}.
"""
if not platform.isWindows():
self.originalHandler = signal.signal(signal.SIGCHLD, signal.SIG_DFL)
开发者ID:antong,项目名称:twisted,代码行数:7,代码来源:reactormixins.py
示例3: child
def child(self, path):
"""
Create and return a new L{FilePath} representing a path contained by
C{self}.
@param path: The base name of the new L{FilePath}. If this contains
directory separators or parent references it will be rejected.
@type path: L{bytes}
@raise InsecurePath: If the result of combining this path with C{path}
would result in a path which is not a direct child of this path.
@return: The child path.
@rtype: L{FilePath}
"""
if platform.isWindows() and path.count(b":"):
# Catch paths like C:blah that don't have a slash
raise InsecurePath("%r contains a colon." % (path,))
norm = normpath(path)
if self.sep in norm:
raise InsecurePath("%r contains one or more directory separators" % (path,))
newpath = abspath(joinpath(self.path, norm))
if not newpath.startswith(self.path):
raise InsecurePath("%r is not a child of %s" % (newpath, self.path))
return self.clonePath(newpath)
开发者ID:RCBiczok,项目名称:VTK,代码行数:25,代码来源:filepath.py
示例4: checkProtocol
def checkProtocol(stdioOb):
from twisted.python.runtime import platform
if platform.isWindows():
self.assertIsInstance(stdioOb.proto, basic.LineReceiver)
else:
self.assertIsInstance(stdioOb.protocol, basic.LineReceiver)
stdioOb.loseConnection()
开发者ID:anrysev,项目名称:twisted,代码行数:7,代码来源:test_endpoints.py
示例5: _sendSignal
def _sendSignal(self, signal):
if platform.isWindows():
raise usage.UsageError("You can't send signals on Windows (XXX TODO)")
dbdir = self.parent.getStoreDirectory()
serverpid = int(file(os.path.join(dbdir, 'run', 'axiomatic.pid')).read())
os.kill(serverpid, signal)
return serverpid
开发者ID:ldanielburr,项目名称:axiom,代码行数:7,代码来源:axiomatic.py
示例6: _parseWorker
def _parseWorker(reactor, name, executable=None):
"""
Constructs a process endpoint for a spreadflow worker process.
Args:
reactor: The reactor passed to ``clientFromString``.
name (str): The partition name this worker should operate on.
executable (Optional[str]). Path to the spreadflow-twistd command.
Returns:
A client process endpoint
"""
if executable is None:
executable = sys.argv[0]
logger = 'spreadflow_core.scripts.spreadflow_twistd.StderrLogger'
args = [executable, '-n', '--logger', logger, '--multiprocess',
'--partition', name]
if not platform.isWindows():
args.extend(['--pidfile', ''])
fds = {0: "w", 1: "r", 2: 2}
return ProcessEndpoint(reactor, executable, args=args,
env=os.environ.copy(), childFDs=fds)
开发者ID:spreadflow,项目名称:spreadflow-core,代码行数:26,代码来源:spreadflow_worker.py
示例7: getArguments
def getArguments(self, store, args):
run = store.dbdir.child("run")
logs = run.child("logs")
handleLogfile = True
handlePidfile = True
for arg in args:
if arg.startswith("--logfile=") or arg in (
"-l", "--logfile", "-n", "--nodaemon"
):
handleLogfile = False
elif arg.startswith("--pidfile=") or arg == "--pidfile":
handlePidfile = False
if handleLogfile:
if not logs.exists():
logs.makedirs()
args.extend(["--logfile", logs.child("axiomatic.log").path])
if not platform.isWindows() and handlePidfile:
args.extend(["--pidfile", run.child("axiomatic.pid").path])
args.extend(["axiomatic-start", "--dbdir", store.dbdir.path])
if store.journalMode is not None:
args.extend(['--journal-mode', store.journalMode.encode('ascii')])
return args
开发者ID:twisted,项目名称:axiom,代码行数:25,代码来源:axiomatic.py
示例8: test_disconnectWhileProducing
def test_disconnectWhileProducing(self):
"""
If C{loseConnection} is called while a producer is registered with the
transport, the connection is closed after the producer is unregistered.
"""
reactor = self.buildReactor()
# For some reason, pyobject/pygtk will not deliver the close
# notification that should happen after the unregisterProducer call in
# this test. The selectable is in the write notification set, but no
# notification ever arrives. Probably for the same reason #5233 led
# win32eventreactor to be broken.
skippedReactors = ["Glib2Reactor", "Gtk2Reactor"]
reactorClassName = reactor.__class__.__name__
if reactorClassName in skippedReactors and platform.isWindows():
raise SkipTest("A pygobject/pygtk bug disables this functionality " "on Windows.")
class Producer:
def resumeProducing(self):
log.msg("Producer.resumeProducing")
self.listen(reactor, ServerFactory.forProtocol(Protocol))
finished = Deferred()
finished.addErrback(log.err)
finished.addCallback(lambda ign: reactor.stop())
class ClientProtocol(Protocol):
"""
Protocol to connect, register a producer, try to lose the
connection, unregister the producer, and wait for the connection to
actually be lost.
"""
def connectionMade(self):
log.msg("ClientProtocol.connectionMade")
self.transport.registerProducer(Producer(), False)
self.transport.loseConnection()
# Let the reactor tick over, in case synchronously calling
# loseConnection and then unregisterProducer is the same as
# synchronously calling unregisterProducer and then
# loseConnection (as it is in several reactors).
reactor.callLater(0, reactor.callLater, 0, self.unregister)
def unregister(self):
log.msg("ClientProtocol unregister")
self.transport.unregisterProducer()
# This should all be pretty quick. Fail the test
# if we don't get a connectionLost event really
# soon.
reactor.callLater(1.0, finished.errback, Failure(Exception("Connection was not lost")))
def connectionLost(self, reason):
log.msg("ClientProtocol.connectionLost")
finished.callback(None)
clientFactory = ClientFactory()
clientFactory.protocol = ClientProtocol
self.connect(reactor, clientFactory)
self.runReactor(reactor)
开发者ID:samsoft00,项目名称:careervacancy,代码行数:60,代码来源:connectionmixins.py
示例9: test_parseOptionsHelp
def test_parseOptionsHelp(self):
"""
L{Start.parseOptions} writes usage information to stdout if C{"--help"}
is in the argument list it is passed and L{twistd.run} is not called.
"""
start = axiomatic.Start()
start.run = None
original = sys.stdout
sys.stdout = stdout = StringIO.StringIO()
try:
self.assertRaises(SystemExit, start.parseOptions, ["--help"])
finally:
sys.stdout = original
# Some random options that should be present. This is a bad test
# because we don't control what C{opt_help} actually does and we don't
# even really care as long as it's the same as what I{twistd --help}
# does. We could try running them both and comparing, but then we'd
# still want to do some sanity check against one of them in case we end
# up getting the twistd version incorrectly somehow... -exarkun
self.assertIn("--reactor", stdout.getvalue())
if not platform.isWindows():
# This isn't an option on Windows, so it shouldn't be there.
self.assertIn("--uid", stdout.getvalue())
# Also, we don't want to see twistd plugins here.
self.assertNotIn("axiomatic-start", stdout.getvalue())
开发者ID:bne,项目名称:squeal,代码行数:27,代码来源:test_axiomatic.py
示例10: stopped
def stopped(ignored):
# Should still be possible to recv on portSocket. If
# it was shutdown, the exception would be EINVAL instead.
exc = self.assertRaises(socket.error, portSocket.recvfrom, 1)
if platform.isWindows() and _PY3:
self.assertEqual(exc.args[0], errno.WSAEWOULDBLOCK)
else:
self.assertEqual(exc.args[0], errno.EAGAIN)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:8,代码来源:test_socket.py
示例11: setContent
def setContent(self, content, ext=".new"):
sib = self.siblingExtension(ext)
f = sib.open("w")
f.write(content)
f.close()
if platform.isWindows() and exists(self.path):
os.unlink(self.path)
os.rename(sib.path, self.path)
开发者ID:hortonworkstest,项目名称:hortonworks-sandbox,代码行数:8,代码来源:filepath.py
示例12: setContent
def setContent(self, content, ext='.new'):
"""
Replace the file at this path with a new file that contains the given
bytes, trying to avoid data-loss in the meanwhile.
On UNIX-like platforms, this method does its best to ensure that by the
time this method returns, either the old contents I{or} the new contents
of the file will be present at this path for subsequent readers
regardless of premature device removal, program crash, or power loss,
making the following assumptions:
- your filesystem is journaled (i.e. your filesystem will not
I{itself} lose data due to power loss)
- your filesystem's C{rename()} is atomic
- your filesystem will not discard new data while preserving new
metadata (see U{http://mjg59.livejournal.com/108257.html} for more
detail)
On most versions of Windows there is no atomic C{rename()} (see
U{http://bit.ly/win32-overwrite} for more information), so this method
is slightly less helpful. There is a small window where the file at
this path may be deleted before the new file is moved to replace it:
however, the new file will be fully written and flushed beforehand so in
the unlikely event that there is a crash at that point, it should be
possible for the user to manually recover the new version of their data.
In the future, Twisted will support atomic file moves on those versions
of Windows which I{do} support them: see U{Twisted ticket
3004<http://twistedmatrix.com/trac/ticket/3004>}.
This method should be safe for use by multiple concurrent processes, but
note that it is not easy to predict which process's contents will
ultimately end up on disk if they invoke this method at close to the
same time.
@param content: The desired contents of the file at this path.
@type content: L{str}
@param ext: An extension to append to the temporary filename used to
store the bytes while they are being written. This can be used to
make sure that temporary files can be identified by their suffix,
for cleanup in case of crashes.
@type ext: C{str}
"""
sib = self.temporarySibling(ext)
f = sib.open('w')
try:
f.write(content)
finally:
f.close()
if platform.isWindows() and exists(self.path):
os.unlink(self.path)
os.rename(sib.path, self.path)
开发者ID:Varriount,项目名称:Colliberation,代码行数:56,代码来源:filepath.py
示例13: test_getProgramsMenuPath
def test_getProgramsMenuPath(self):
"""
L{getProgramsMenuPath} guesses the programs menu path on non-win32
platforms. On non-win32 it will try to figure out the path by
examining the registry.
"""
if not platform.isWindows():
self.assertEqual(win32.getProgramsMenuPath(),
"C:\\Windows\\Start Menu\\Programs")
else:
self.assertIsInstance(win32.getProgramsMenuPath(), str)
开发者ID:Architektor,项目名称:PySnip,代码行数:11,代码来源:test_win32.py
示例14: getArguments
def getArguments(self, store, args):
run = store.dbdir.child("run")
logs = run.child("logs")
if "--logfile" not in args and "-l" not in args and "--nodaemon" not in args and "-n" not in args:
if not logs.exists():
logs.makedirs()
args.extend(["--logfile", logs.child("axiomatic.log").path])
if not platform.isWindows() and "--pidfile" not in args:
args.extend(["--pidfile", run.child("axiomatic.pid").path])
args.extend(["axiomatic-start", "--dbdir", store.dbdir.path])
return args
开发者ID:ddormer,项目名称:axiom,代码行数:11,代码来源:axiomatic.py
示例15: test_gid
def test_gid(self):
"""
Should be the current user by default
"""
if platform.isWindows():
raise SkipTest('Windows-only test')
r = _spawnDefaultArgs('exec')
self.assertEqual(r['gid'], os.getegid())
r = _spawnDefaultArgs('exec', gid='foo')
self.assertEqual(r['gid'], 'foo')
开发者ID:hagna,项目名称:mold,代码行数:12,代码来源:test_process.py
示例16: get
def get(self):
yield ('start', None, Start, 'Launch the given Axiom database')
if not platform.isWindows():
yield ('stop', None, Stop, 'Stop the server running from the given Axiom database')
yield ('status', None, Status, 'Report whether a server is running from the given Axiom database')
from axiom import plugins
for plg in getPlugins(IAxiomaticCommand, plugins):
try:
yield (plg.name, None, plg, plg.description)
except AttributeError:
raise RuntimeError("Maldefined plugin: %r" % (plg,))
开发者ID:ldanielburr,项目名称:axiom,代码行数:12,代码来源:axiomatic.py
示例17: __init__
def __init__(self, controller, id, who, keeplog=None):
"""
Ctor.
:param controller: The node controller this worker was created by.
:type controller: instance of NodeController
:param id: The ID of the worker.
:type id: str
:param who: Who triggered creation of this worker.
:type who: str
:param keeplog: If not `None`, buffer log message received to be later
retrieved via getlog(). If `0`, keep infinite log internally.
If `> 0`, keep at most such many log entries in buffer.
:type keeplog: int or None
"""
self._logger = make_logger()
self._controller = controller
self.id = id
self.who = who
self.pid = None
self.status = u'starting'
self.created = datetime.utcnow()
self.connected = None
self.started = None
self.proto = None
self.pinfo = None
self._log_entries = deque(maxlen=10)
if platform.isWindows():
self._log_fds = [2]
else:
self._log_fds = [1, 2]
self._log_lineno = 0
self._log_topic = u'crossbar.worker.{}.on_log'.format(self.id)
self._log_rich = None # Does not support rich logs
# track stats for worker->controller traffic
self._stats = {}
self._stats_printer = None
# A deferred that resolves when the worker is ready.
self.ready = Deferred()
# A deferred that resolves when the worker has exited.
self.exit = Deferred()
self.exit.addBoth(self._dump_remaining_log)
开发者ID:goeddea,项目名称:crossbar,代码行数:52,代码来源:worker.py
示例18: getServerObjType
def getServerObjType(server):
obj_type = SrcdsServerProcessTwisted
if platform.isWindows():
if "subtype" in server and server["subtype"] == "svc":
from srcds_win32 import SrcdsServerServiceWin32
obj_type = SrcdsServerServiceWin32
else:
from srcds_win32 import SrcdsServerProcessWin32
obj_type = SrcdsServerProcessWin32
return obj_type
开发者ID:nationgaming,项目名称:openmaul,代码行数:13,代码来源:__init__.py
示例19: test_normalFileStandardOut
def test_normalFileStandardOut(self):
"""
If L{StandardIO} is created with a file descriptor which refers to a
normal file (ie, a file from the filesystem), L{StandardIO.write}
writes bytes to that file. In particular, it does not immediately
consider the file closed or call its protocol's C{connectionLost}
method.
"""
onConnLost = defer.Deferred()
proto = ConnectionLostNotifyingProtocol(onConnLost)
path = filepath.FilePath(self.mktemp())
self.normal = normal = path.open('w')
self.addCleanup(normal.close)
kwargs = dict(stdout=normal.fileno())
if not platform.isWindows():
# Make a fake stdin so that StandardIO doesn't mess with the *real*
# stdin.
r, w = os.pipe()
self.addCleanup(os.close, r)
self.addCleanup(os.close, w)
kwargs['stdin'] = r
connection = stdio.StandardIO(proto, **kwargs)
# The reactor needs to spin a bit before it might have incorrectly
# decided stdout is closed. Use this counter to keep track of how
# much we've let it spin. If it closes before we expected, this
# counter will have a value that's too small and we'll know.
howMany = 5
count = itertools.count()
def spin():
for value in count:
if value == howMany:
connection.loseConnection()
return
connection.write(str(value))
break
reactor.callLater(0, spin)
reactor.callLater(0, spin)
# Once the connection is lost, make sure the counter is at the
# appropriate value.
def cbLost(reason):
self.assertEquals(count.next(), howMany + 1)
self.assertEquals(
path.getContent(),
''.join(map(str, range(howMany))))
onConnLost.addCallback(cbLost)
return onConnLost
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:50,代码来源:test_stdio.py
示例20: getProgramsMenuPath
def getProgramsMenuPath():
"""
Get the path to the Programs menu.
Probably will break on non-US Windows.
@return: the filesystem location of the common Start Menu->Programs.
@rtype: L{str}
"""
if not platform.isWindows():
return "C:\\Windows\\Start Menu\\Programs"
keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders'
hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
keyname, 0, win32con.KEY_READ)
return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0]
开发者ID:Architektor,项目名称:PySnip,代码行数:15,代码来源:win32.py
注:本文中的twisted.python.runtime.platform.isWindows函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论