Ejemplo n.º 1
0
 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']
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
Archivo: win32.py Proyecto: jxta/cc
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,))
Ejemplo n.º 6
0
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]
Ejemplo n.º 7
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'])
Ejemplo n.º 9
0
    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'])
Ejemplo n.º 10
0
 def postOptions(self):
     if platform.isWinNT():
         self._win32PostOptions()
     else:
         self._unixPostOptions()
Ejemplo n.º 11
0
 def _removePID(self):
     if not platform.isWinNT():
         twistd.removePID(self['pidfile'])
Ejemplo n.º 12
0
 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'])
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
 def _startApplication(self):
     if not platform.isWinNT():
         twistd.startApplication(self, self.application)
     else:
         service.IService(self.application).privilegedStartService()
         app.startApplication(self.application, False)
Ejemplo n.º 15
0
        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):
Ejemplo n.º 16
0
 def _startApplication(self):
     if not platform.isWinNT():
         twistd.startApplication(self, self.application)
     else:
         service.IService(self.application).privilegedStartService()
         app.startApplication(self.application, False)
Ejemplo n.º 17
0
 def _removePID(self):
     if not platform.isWinNT():
         twistd.removePID(self['pidfile'])
Ejemplo n.º 18
0
 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'])
Ejemplo n.º 19
0
 def _startLogging(self):
     if not platform.isWinNT():
         twistd.startLogging(self['logfile'], self['syslog'],
                             self['prefix'], self['nodaemon'])
     else:
         twistd.startLogging('-')  # self['logfile']