示例#1
0
def main():
    mountdir = sys.argv[1]
    #secret = sys.argv[2]

    c = pwrfscli(mountdir)
    loop()
    c._unmount()
    return 0
示例#2
0
文件: pwrmount.py 项目: rep/pwrfs
def main():
	mountdir = sys.argv[1]
	#secret = sys.argv[2]

	c = pwrfscli(mountdir)
	loop()
	c._unmount()
	return 0
示例#3
0
def main():
	n = Node(cert='serverside.pem')
	im = Instamaster()
	ref = n.register(im, 'im')
	n._on('connection', im.on_new_conn)
	n.listen(port=20001)
	print 'Instamaster at', n.refurl(ref)

	loop()

	return 0
示例#4
0
def main():
    n = Node(cert='serverside.pem')
    im = Instamaster()
    ref = n.register(im, 'im')
    n._on('connection', im.on_new_conn)
    n.listen(port=20001)
    print 'Instamaster at', n.refurl(ref)

    loop()

    return 0
示例#5
0
文件: fserver.py 项目: rep/pwrfs
def main():
	global SDIR
	SDIR = sys.argv[1]
	secret = sys.argv[2]

	if not (os.path.exists(SDIR) and os.path.isdir(SDIR)):
		os.mkdir(SDIR)

	n = Node(cert=None)
	n.listen(port=PORT)
	gs = Fileserver()
	ref = n.register(gs, cap=secret)
	logging.info('gs at {0}'.format(n.refurl(ref)))

	loop()
	return 0
示例#6
0
文件: fserver.py 项目: rep/pwrfs
def main():
    global SDIR
    SDIR = sys.argv[1]
    secret = sys.argv[2]

    if not (os.path.exists(SDIR) and os.path.isdir(SDIR)):
        os.mkdir(SDIR)

    n = Node(cert=None)
    n.listen(port=PORT)
    gs = Fileserver()
    ref = n.register(gs, cap=secret)
    logging.info('gs at {0}'.format(n.refurl(ref)))

    loop()
    return 0
示例#7
0
文件: instashare.py 项目: rep/pwrcall
def main(options, action, args):
    n = Node(cert=CERTPATH)

    if action == 'listen':
        ic = Instaclient(n)
        loop()
    elif action == 'send':
        targetcap, fp = args

        if not (os.path.exists(fp) and os.path.isfile(fp)):
            print fp, 'not a file'
            return 1

        im = n.establish(MASTERURL)

        def established(rim):
            p = rim.call('open', targetcap)

            def donecb(r):
                print 'done:', r
                n.shutdown()
                unloop()

            def prsink(r):
                print 'sink:', r
                r.notify('init', os.path.basename(fp))
                fs = Filestreamer(open(fp, 'rb'), r, rim.conn)
                fs.p._when(donecb)
                fs.p._except(donecb)

            def prexcept(e):
                print 'Error:', e
                n.shutdown()
                unloop()

            p._when(prsink)
            p._except(prexcept)

        im._when(established)
        loop()

    return 0
示例#8
0
文件: instashare.py 项目: rep/pwrcall
def main(options, action, args):
	n = Node(cert=CERTPATH)

	if action == 'listen':
		ic = Instaclient(n)
		loop()
	elif action == 'send':
		targetcap, fp = args

		if not (os.path.exists(fp) and os.path.isfile(fp)):
			print fp, 'not a file'
			return 1

		im = n.establish(MASTERURL)

		def established(rim):
			p = rim.call('open', targetcap)

			def donecb(r):
				print 'done:', r
				n.shutdown()
				unloop()

			def prsink(r):
				print 'sink:' , r
				r.notify('init', os.path.basename(fp))
				fs = Filestreamer(open(fp, 'rb'), r, rim.conn)
				fs.p._when(donecb)
				fs.p._except(donecb)

			def prexcept(e):
				print 'Error:', e
				n.shutdown()
				unloop()

			p._when(prsink)
			p._except(prexcept)

		im._when(established)
		loop()

	return 0
示例#9
0
文件: pwr.py 项目: rep/pwrcall
	def list(self):
		return dict([(k, [v.fpath, v.modname, str(v.ref)]) for k,v in self.apps.items()])

	@expose
	def get(self, appid):
		a = self.apps.get(appid, None)
		if a == None:
			raise NodeException('Nonexisting app.')
		return a.ref

	@expose
	def restart(self, appid):
		a = self.apps.get(appid, None)
		if a == None:
			raise NodeException('Nonexisting app.')
		nmod, nref = load_pwrobj(a.fpath, a.modname)
		a.modref = nmod
		a.ref = nref
		return nref
		

if __name__ == '__main__':
	n = Node(cert=CERT)
	n.listen(port=PORT)
	appsrvobj = Appserver()
	ref = n.register(appsrvobj)
	print 'appserver at', n.refurl(ref)

	loop()

示例#10
0
		self.obj = n.establish(url)
		r = self.obj.call('add', 10, 31)
		r._when(self.done)
		return self.donaterunpromise

	def done(self, r):
		print 'done using the object, result:', r
		self.donaterunpromise._resolve('Thanks, i am done!.')
		later(3, self.retry)

	def works(self, r):
		print 'reusing worked, result:', r
		later(3, self.retry)

	def err(self, e):
		print 'reusing error, e:', e

	def retry(self):
		if self.obj:
			r = self.obj.call('add', 40, 31)
			r._when(self.works)
			r._except(self.err)
			

ref = n.register(Giftreceiver(), cap='giftreceive')
n.listen(port=10001)
print 'giftreceiver ready at', n.refurl(ref)

loop()

示例#11
0
文件: pwrweb.py 项目: rep/pwrcall
def main():
    pw = pwrweb()
    loop()
    return 0
示例#12
0
文件: pwrweb.py 项目: rep/pwrcall
def main():
	pw = pwrweb()
	loop()
	return 0