示例#1
0
文件: launcher.py 项目: arjan/sparked
def launchApplication(argv):
    options = Options()
    sparkedOpts, appName, appOpts = splitOptions(argv)
    options.parseOptions(sparkedOpts)

    if not appName:
        raise usage.UsageError("Missing application name")

    appModule, appName = loadModule(appName)

    if hasattr(appModule, 'Options'):
        opts = appModule.Options()
    else:
        opts = application.Options()

    opts.appName = appName
    if not hasattr(opts, 'longdesc'):
        opts.longdesc = appModule.__doc__
    opts.parseOptions(appOpts)

    if options['no-subprocess']:
        return run(appName)

    options['pidfile'] = application.getPath('pidfile', appName, opts).path
    tempPath = application.getPath("temp", appName, opts)
    return runInSubprocess(appName, options, os.environ, tempPath)
示例#2
0
 def testDBPath(self):
     self.assertEqual("/tmp/foo/db", getPath("db", "foo", {}).path)
     self.assertEqual("/tmp/bar/db", getPath("db", "foo", {'id': 'bar'}).path)
     self.assertEqual("/beh/dinges/db", getPath("db", "foo", {'temp-path': '/beh/dinges'}).path)
     self.assertEqual("/var/aap", getPath("db", "foo", {'db-path': '/var/aap/'}).path)
     self.assertEqual("/var/aap", getPath("db", "foo", {'db-path': '/var/aap/', 'system-paths': True}).path)
     self.assertEqual("/var/lib/foo", getPath("db", "foo", {'system-paths': True}).path)
     self.assertEqual("/var/lib/bar", getPath("db", "foo", {'system-paths': True, 'id': 'bar'}).path)
示例#3
0
 def testPidPath(self):
     self.assertEqual("/tmp/foo/sparkd.pid", getPath("pidfile", "foo", {}).path)
     self.assertEqual("/tmp/bar/sparkd.pid", getPath("pidfile", "foo", {'id': 'bar'}).path)
     self.assertEqual("/beh/dinges/sparkd.pid", getPath("pidfile", "foo", {'temp-path': '/beh/dinges'}).path)
     self.assertEqual("/aap.pid", getPath("pidfile", "foo", {'pidfile': '/aap.pid'}).path)
     self.assertEqual("/aap.pid", getPath("pidfile", "foo", {'pidfile': '/aap.pid', 'system-paths': True}).path)
     self.assertEqual("/var/run/foo.pid", getPath("pidfile", "foo", {'system-paths': True}).path)
     self.assertEqual("/var/run/bar.pid", getPath("pidfile", "foo", {'system-paths': True, 'id': 'bar'}).path)
示例#4
0
 def testLogPath(self):
     self.assertEqual("/tmp/foo/sparkd.log", getPath("logfile", "foo", {}).path)
     self.assertEqual("/tmp/bar/sparkd.log", getPath("logfile", "foo", {'id': 'bar'}).path)
     self.assertEqual("/beh/dinges/sparkd.log", getPath("logfile", "foo", {'temp-path': '/beh/dinges'}).path)
     self.assertEqual("/aap.log", getPath("logfile", "foo", {'logfile': '/aap.log'}).path)
     self.assertEqual("/aap.log", getPath("logfile", "foo", {'logfile': '/aap.log', 'system-paths': True}).path)
     self.assertEqual("/var/log/foo.log", getPath("logfile", "foo", {'system-paths': True}).path)
     self.assertEqual("/var/log/bar.log", getPath("logfile", "foo", {'system-paths': True, 'id': 'bar'}).path)
示例#5
0
 def testDataPath(self):
     c = os.getcwd()
     self.assertEqual(c+"/data", getPath("data", "foo", {}).path)
     self.assertEqual(c+"/data", getPath("data", "foo", {'id': 'bar'}).path)
     self.assertEqual(c+"/data", getPath("data", "foo", {'temp-path': '/beh/dinges'}).path)
     self.assertEqual("/var/aap", getPath("data", "foo", {'data-path': '/var/aap/'}).path)
     self.assertEqual("/var/aap", getPath("data", "foo", {'data-path': '/var/aap/', 'system-paths': True}).path)
     self.assertEqual("/usr/share/foo", getPath("data", "foo", {'system-paths': True}).path)
     self.assertEqual("/usr/share/foo", getPath("data", "foo", {'system-paths': True, 'id': 'bar'}).path)
示例#6
0
 def testPathExpansion(self):
     self.assertEqual(os.getenv("HOME"), getPath("data", "foo", {"data-path": "~"}).path)
     self.assertEqual(os.getenv("HOME")+"/tmp", getPath("data", "foo", {"data-path": "~/tmp"}).path)
示例#7
0
 def testTempPath(self):
     self.assertEqual("/tmp/foo", getPath("temp", "foo", {}).path)
     self.assertEqual("/tmp/bar", getPath("temp", "foo", {'id': 'bar'}).path)
     self.assertEqual("/beh/dinges", getPath("temp", "foo", {'temp-path': '/beh/dinges'}).path)
     self.assertEqual("/tmp/foo", getPath("temp", "foo", {'system-paths': True}).path)