本文整理汇总了Python中twisted.python.util.sibpath函数的典型用法代码示例。如果您正苦于以下问题:Python sibpath函数的具体用法?Python sibpath怎么用?Python sibpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sibpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgradeMaster
def upgradeMaster(config):
basedir = os.path.expanduser(config['basedir'])
m = Maker(config)
# TODO: check Makefile
# TODO: check TAC file
# check web files: index.html, default.css, robots.txt
m.upgrade_public_html({
'bg_gradient.jpg' : util.sibpath(__file__, "../status/web/files/bg_gradient.jpg"),
'default.css' : util.sibpath(__file__, "../status/web/files/default.css"),
'robots.txt' : util.sibpath(__file__, "../status/web/files/robots.txt"),
'favicon.ico' : util.sibpath(__file__, "../status/web/files/favicon.ico"),
})
m.populate_if_missing(os.path.join(basedir, "master.cfg.sample"),
util.sibpath(__file__, "sample.cfg"),
overwrite=True)
# if index.html exists, use it to override the root page tempalte
m.move_if_present(os.path.join(basedir, "public_html/index.html"),
os.path.join(basedir, "templates/root.html"))
from buildbot.db import connector, dbspec
spec = dbspec.DBSpec.from_url(config["db"], basedir)
# TODO: check that TAC file specifies the right spec
# upgrade the db
from buildbot.db.schema import manager
sm = manager.DBSchemaManager(spec, basedir)
sm.upgrade()
# check the configuration
rc = m.check_master_cfg()
if rc:
return rc
if not config['quiet']: print "upgrade complete"
return 0
示例2: __init__
def __init__(self, highscore, config):
service.MultiService.__init__(self)
self.setName('highscore.www')
self.highscore = highscore
self.config = config
self.port = config.www.get('port', 8080)
self.port_service = None
self.site = None
self.site_public_html = None
self.root = root = static.Data('placeholder', 'text/plain')
resource
#root.putChild('', resource.HighscoresResource(self.highscore))
print(util.sibpath(__file__, 'content'))
self.root = root = static.File(util.sibpath(__file__, 'content'))
root.putChild('api', resource.ApiResource(self.highscore))
root.putChild('plugins', resource.PluginsResource(self.highscore))
self.site = server.Site(root)
port = "tcp:%d" % self.port if type(self.port) == int else self.port
self.port_service = strports.service(port, self.site)
self.port_service.setServiceParent(self)
示例3: getToplevel
def getToplevel(session):
root = File(util.sibpath(__file__, "web-data/tpl/default"))
root.putChild("web", ScreenPage(session, util.sibpath(__file__, "web"), True) ) # "/web/*"
root.putChild("web-data", File(util.sibpath(__file__, "web-data")))
root.putChild("file", FileStreamer())
root.putChild("grab", GrabResource())
res = IPKGResource()
root.putChild("opkg", res)
root.putChild("ipkg", res)
root.putChild("play", ServiceplayerResource(session))
root.putChild("wap", RedirectorResource("/mobile/"))
root.putChild("mobile", ScreenPage(session, util.sibpath(__file__, "mobile"), True) )
root.putChild("upload", UploadResource())
root.putChild("servicelist", ServiceList(session))
root.putChild("streamcurrent", RedirecToCurrentStreamResource(session))
if config.plugins.Webinterface.includemedia.value is True:
root.putChild("media", File("/media"))
root.putChild("hdd", File("/media/hdd"))
importExternalModules()
for child in externalChildren:
if len(child) > 1:
root.putChild(child[0], child[1])
return root
示例4: __init__
def __init__(self, deviceService):
"""
:type deviceService: txopenbci.control.DeviceService
"""
Resource.__init__(self)
self.putChild("control", CommandResource(deviceService))
self.putChild("stream", SampleStreamer(deviceService))
self.putChild("static", File(sibpath(__file__, "webpages")))
self.putChild("", File(os.path.join(sibpath(__file__, "webpages"), 'index.html')))
示例5: ensureTwistedPair
def ensureTwistedPair(self):
try:
import twisted.pair
except ImportError:
import new
m = new.module("twisted.pair")
sys.modules["twisted.pair"] = m
global twisted
twisted.pair = m
m.__file__ = os.path.join(sibpath(__file__, "twisted_pair"), "__init__.pyc")
m.__path__ = [sibpath(__file__, "twisted_pair")]
示例6: setUp
def setUp(self):
self.basedir = "test_slavecommand"
if not os.path.isdir(self.basedir):
os.mkdir(self.basedir)
self.subdir = os.path.join(self.basedir, "subdir")
if not os.path.isdir(self.subdir):
os.mkdir(self.subdir)
self.builder = FakeSlaveBuilder(self.usePTY, self.basedir)
self.emitcmd = util.sibpath(__file__, "emit.py")
self.subemitcmd = os.path.join(util.sibpath(__file__, "subdir"),
"emit.py")
self.sleepcmd = util.sibpath(__file__, "sleep.py")
示例7: autostart
def autostart(reason, **kwargs):
if reason == 0 and "session" in kwargs:
session = kwargs["session"]
root = File(eEnv.resolve("${libdir}/enigma2/python/Plugins/Extensions/WebAdmin/web-data"))
root.putChild("web", ScreenPage(session, util.sibpath(__file__, "web"), True))
root.putChild("mobile", ScreenPage(session, util.sibpath(__file__, "mobile"), True))
root.putChild("tmp", File("/tmp"))
root.putChild("uploadtext", UploadTextResource())
root.putChild("uploadpkg", UploadPkgResource())
root.putChild("pkg", PKGResource())
root.putChild("script", Script())
addExternalChild(("webadmin", root, "WebAdmin", 1, True, "_self"))
示例8: setUpFakeHome
def setUpFakeHome(self):
user_home = os.path.abspath(tempfile.mkdtemp())
os.makedirs(os.path.join(user_home, '.ssh'))
shutil.copyfile(
sibpath(__file__, 'id_dsa'),
os.path.join(user_home, '.ssh', 'id_dsa'))
shutil.copyfile(
sibpath(__file__, 'id_dsa.pub'),
os.path.join(user_home, '.ssh', 'id_dsa.pub'))
os.chmod(os.path.join(user_home, '.ssh', 'id_dsa'), 0600)
real_home, os.environ['HOME'] = os.environ['HOME'], user_home
return real_home, user_home
示例9: task_installPrivateData
def task_installPrivateData(self, private=sibpath(__file__, 'private.py')):
"""
Install private config.
"""
with settings(user=self.serviceUser):
put(sibpath(__file__, 'config.py'),
os.path.join(self.configDir, "config.py"))
if FilePath(private).exists():
put(sibpath(__file__, 'private.py'),
os.path.join(self.configDir, "private.py"), mode=0600)
else:
abort('Missing private config.')
示例10: task_installTestData
def task_installTestData(self, force=None):
"""
Do test environment setup (with fake passwords, etc).
"""
if env.get('environment') == 'production':
abort("Don't use testInit in production.")
with settings(user=self.serviceUser), cd(self.configDir):
if force or not files.exists('private.py'):
puts('Using sample private.py and config.py')
put(sibpath(__file__, 'private.py.sample'),
os.path.join(self.configDir, "private.py"), mode=0600)
put(sibpath(__file__, 'config.py.sample'),
os.path.join(self.configDir, "config.py"))
示例11: createMaster
def createMaster(config):
m = Maker(config)
m.mkdir()
m.chdir()
contents = masterTAC % config
m.makeTAC(contents)
m.sampleconfig(util.sibpath(__file__, "sample.cfg"))
m.public_html(util.sibpath(__file__, "../status/web/index.html"),
util.sibpath(__file__, "../status/web/classic.css"),
util.sibpath(__file__, "../status/web/robots.txt"),
)
m.makefile()
if not m.quiet: print "buildmaster configured in %s" % m.basedir
示例12: createMaster
def createMaster(config):
m = Maker(config)
m.mkdir()
m.chdir()
contents = masterTAC % config
m.makeTAC(contents)
m.sampleconfig(util.sibpath(__file__, "sample.cfg"))
m.public_html({
'bg_gradient.jpg' : util.sibpath(__file__, "../status/web/bg_gradient.jpg"),
'default.css' : util.sibpath(__file__, "../status/web/default.css"),
'robots.txt' : util.sibpath(__file__, "../status/web/robots.txt"),
})
m.makefile()
if not m.quiet: print "buildmaster configured in %s" % m.basedir
示例13: getExamples
def getExamples():
liveChildren = {}
for mod in os.listdir(util.sibpath(__file__, ".")):
if mod.startswith("_") or not mod.endswith(".py"):
continue
moduleId = mod[:-3]
print "Found example 'examples.%s.example'" % (moduleId,)
example = reflect.namedAny("examples.%s.Example" % (moduleId,))
class Viewer(ExampleViewer):
pass
example.moduleId = moduleId
doc = unicode(example.__doc__)
title = getattr(example, "title", None)
if not title:
if doc:
# Take the first line of the docstring.
title = u"".join(doc.split(u"\n")[:1])
else:
title = splitNerdyCaps(moduleId)
example.title = title
Viewer.example = example
Viewer.liveChildren = {"example": example}
liveChildren[moduleId] = Viewer
return liveChildren
示例14: _testLogFiles
def _testLogFiles(self, mode):
basedir = "test_shell.testLogFiles"
self.setUpBuilder(basedir)
# emitlogs.py writes two lines to stdout and two logfiles, one second
# apart. Then it waits for us to write something to stdin, then it
# writes one more line.
if mode != 3:
# we write something to the log file first, to exercise the logic
# that distinguishes between the old file and the one as modified
# by the ShellCommand. We set the timestamp back 5 seconds so
# that timestamps can be used to distinguish old from new.
log2file = os.path.join(basedir, "log2.out")
f = open(log2file, "w")
f.write("dummy text\n")
f.close()
earlier = time.time() - 5
os.utime(log2file, (earlier, earlier))
if mode == 3:
# mode=3 doesn't create the old logfiles in the first place, but
# then behaves like mode=1 (where the command pauses before
# creating them).
mode = 1
# mode=1 will cause emitlogs.py to delete the old logfiles first, and
# then wait two seconds before creating the new files. mode=0 does
# not do this.
args = {
"command": [sys.executable, util.sibpath(__file__, "emitlogs.py"), "%s" % mode],
"workdir": ".",
"logfiles": {"log2": "log2.out", "log3": "log3.out"},
"keep_stdin_open": True,
}
finishd = self.startCommand(SlaveShellCommand, args)
# The first batch of lines is written immediately. The second is
# written after a pause of one second. We poll once per second until
# we see both batches.
self._check_timeout = 10
d = self._check_and_wait()
def _wait_for_finish(res, finishd):
return finishd
d.addCallback(_wait_for_finish, finishd)
d.addCallback(self.collectUpdates)
def _check(logs):
self.failUnlessEqual(logs["stdout"], self._generateText("stdout"))
if mode == 2:
self.failIf(("log", "log2") in logs)
self.failIf(("log", "log3") in logs)
else:
self.failUnlessEqual(logs[("log", "log2")], self._generateText("log2"))
self.failUnlessEqual(logs[("log", "log3")], self._generateText("log3"))
d.addCallback(_check)
d.addBoth(self._maybePrintError)
return d
示例15: testManyProcesses
def testManyProcesses(self):
def _check(results, protocols):
for p in protocols:
self.assertEquals(p.stages, [1, 2, 3, 4, 5], "[%d] stages = %s" % (id(p.transport), str(p.stages)))
# test status code
f = p.reason
f.trap(error.ProcessTerminated)
self.assertEquals(f.value.exitCode, 23)
exe = sys.executable
scriptPath = util.sibpath(__file__, "process_tester.py")
args = [exe, "-u", scriptPath]
protocols = []
deferreds = []
for i in xrange(50):
p = TestManyProcessProtocol()
protocols.append(p)
reactor.spawnProcess(p, exe, args, env=None)
deferreds.append(p.deferred)
deferredList = defer.DeferredList(deferreds, consumeErrors=True)
deferredList.addCallback(_check, protocols)
return deferredList