def _sendSignal(self, signal): if platform.isWinNT(): 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
def _startLogging(self): if not platform.isWinNT(): twistd.startLogging( self['logfile'], self['syslog'], self['prefix'], self['nodaemon']) else: twistd.startLogging('-') # self['logfile']
def _sendSignal(self, signal): if platform.isWinNT(): 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
def getProgramsMenuPath(): """Get the path to the Programs menu. Probably will break on non-US Windows. @returns: the filesystem location of the common Start Menu->Programs. """ if not platform.isWinNT(): 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]
def get(self): yield ('start', None, Start, 'Launch the given Axiom database') if not platform.isWinNT(): 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 plugin.getPlugins(iaxiom.IAxiomaticCommand, plugins): try: yield (plg.name, None, plg, plg.description) except AttributeError: raise RuntimeError("Maldefined plugin: %r" % (plg,))
def getProgramsMenuPath(): """Get the path to the Programs menu. Probably will break on non-US Windows. @returns: the filesystem location of the common Start Menu->Programs. """ if not platform.isWinNT(): 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]
def get(self): yield ('start', None, Start, 'Launch the given Axiom database') if not platform.isWinNT(): 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 plugin.getPlugins(iaxiom.IAxiomaticCommand, plugins): try: yield (plg.name, None, plg, plg.description) except AttributeError: raise RuntimeError("Maldefined plugin: %r" % (plg, ))
def _fixConfig(self): self['no_save'] = True self['nodaemon'] = self['nodaemon'] or self['debug'] dbdir = self.parent.getStoreDirectory() rundir = os.path.join(dbdir, 'run') if not os.path.exists(rundir): os.mkdir(rundir) if self['logfile'] is None and not self['nodaemon']: logdir = os.path.join(rundir, 'logs') if not os.path.exists(logdir): os.mkdir(logdir) self['logfile'] = os.path.join(logdir, 'axiomatic.log') if platform.isWinNT(): # We're done; no pidfile support. return if self['pidfile'] == 'twistd.pid': self['pidfile'] = os.path.join(rundir, 'axiomatic.pid') elif self['pidfile']: self['pidfile'] = os.path.abspath(self['pidfile'])
def postOptions(self): if platform.isWinNT(): self._win32PostOptions() else: self._unixPostOptions()
def _removePID(self): if not platform.isWinNT(): twistd.removePID(self['pidfile'])
def _checkPID(self): # There *IS* a Windows way to do this, but it doesn't use PIDs. if not platform.isWinNT(): twistd.checkPID(self['pidfile'])
import sys from twisted.application import internet, service, app from twisted.python import usage from twisted.python.runtime import platform from nevow import appserver from nevow.livetrial import runner, testcase if platform.isWinNT(): from twisted.scripts import _twistw as twistd else: from twisted.scripts import twistd class Options(twistd.ServerOptions): def opt_port(self, value): """Specify the TCP port to which to bind the test server (defaults to 8080). """ try: self['port'] = int(value) except ValueError: raise usage.UsageError("Invalid port: %r" % (value,)) def parseArgs(self, *args): self['testmodules'] = args def postOptions(self): app.installReactor(self['reactor']) self['no_save'] = True self['nodaemon'] = True
def _startApplication(self): if not platform.isWinNT(): twistd.startApplication(self, self.application) else: service.IService(self.application).privilegedStartService() app.startApplication(self.application, False)
if not (newcls.__name__ == 'AxiomaticCommand' and newcls.__module__ == _metaASC.__module__): directlyProvides(newcls, plugin.IPlugin, iaxiom.IAxiomaticCommand) return newcls class AxiomaticSubCommand(usage.Options, AxiomaticSubCommandMixin): pass class AxiomaticCommand(usage.Options, AxiomaticSubCommandMixin): __metaclass__ = _metaASC # The following should REALLY be taken care of by Twisted itself. if platform.isWinNT(): from twisted.scripts import _twistw as twistd else: try: from twisted.scripts import _twistd_unix as twistd except ImportError: from twisted.scripts import twistd class Start(twistd.ServerOptions): def noSubCommands(self): raise AttributeError() subCommands = property(noSubCommands) def _fixConfig(self):
def _startLogging(self): if not platform.isWinNT(): twistd.startLogging(self['logfile'], self['syslog'], self['prefix'], self['nodaemon']) else: twistd.startLogging('-') # self['logfile']