当前位置: 首页>>代码示例>>Python>>正文


Python Proxy.callRemote方法代码示例

本文整理汇总了Python中twisted.web.xmlrpc.Proxy.callRemote方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.callRemote方法的具体用法?Python Proxy.callRemote怎么用?Python Proxy.callRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.xmlrpc.Proxy的用法示例。


在下文中一共展示了Proxy.callRemote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
class AddDiary:

    def __init__(self, name, password):
        self.name = name
        self.password = password
        self.proxy = Proxy('http://advogato.org/XMLRPC')

    def __call__(self, filename):
        self.data = open(filename).read()
        d = self.proxy.callRemote('authenticate', self.name, self.password)
        d.addCallbacks(self.login, self.noLogin)

    def noLogin(self, reason):
        print("could not login")
        reactor.stop()

    def login(self, cookie):
        d = self.proxy.callRemote('diary.set', cookie, -1, self.data)
        d.addCallbacks(self.setDiary, self.errorSetDiary)

    def setDiary(self, response):
        reactor.stop()

    def errorSetDiary(self, error):
        print("could not set diary", error)
        reactor.stop()
开发者ID:wellbehavedsoftware,项目名称:wbs-graphite,代码行数:28,代码来源:advogato.py

示例2: modifyDB

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
    def modifyDB(self, ret, cmd, *params):
        abspath = os.path.join(self.shell._path(self.workingDirectory).path, params[0])
        abspath = re.sub(r'\\+', '/', abspath)
        logging.getLogger("twisted").debug(cmd + abspath)
        #print cmd, abspath.decode('utf-8').encode('gbk')
        def printValue(value):
            logging.getLogger("twisted").debug("return:"+value)
        def printErr(e):
            logging.getLogger("twisted").debug("Err:" + e)
        from twisted.web.xmlrpc import Proxy
        try:
            proxy = Proxy('http://localhost:9999/rpc/')
            if cmd == 'del':
                method = 'deleted'
            elif cmd == 'stor':
                method = 'uploaded'
            else:
                print "unexpected db operation"
                return ret
            logging.getLogger("twisted").debug("before remote "+ method)

            print method, abspath.decode('utf-8').encode('gbk')
            proxy.callRemote(method, self.portal.realm.username, abspath).addCallbacks(printValue, printErr)   
        except Exception, e:
            logging.getLogger("twisted").debug(e)
开发者ID:dalinhuang,项目名称:gybprojects,代码行数:27,代码来源:ftpserver.py

示例3: _createPost

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
    def _createPost(self, show, episode, version, info_link, img_link, comment = None, hovertext = None, retries = 0, retryer = None):
        exception = self.master.modules["commands"].exception

        end = " END" if episode == show.episode.total else ""
        title = u"{} {:02d}{}{}".format(show.name.english, episode, version, end)

        img_type = 'video loop="loop" onmouseover="this.play()" onmouseout="this.pause()"' if img_link.endswith("webm") else 'img'
        img = '<{} src="{}" title="{}" style="width: 100%; border-radius: 5px;" />'.format(img_type, img_link, "" if hovertext is None else hovertext.replace('"', '&quot;'))
        comment = "<br><br>{}".format(comment.encode("utf8")) if comment is not None else ""

        user = yield self.config.get("user")
        passwd = yield self.config.get("pass")
        if user is None or passwd is None:
            raise exception(u"No blog username or password in config")

        blog = Proxy("http://commiesubs.com/xmlrpc.php")
        blog.queryFactory.noisy = False
        slug = re.search("([^/]+)/?$", show.blog).group(1)
        categories = ["Releases"] #, "DxS a shit"]
        result = yield blog.callRemote("wp.getTerms", 0, user, passwd, "category")
        for term in result:
            if term["slug"] == slug:
                categories.append(term["name"])

        try:
            post_id = yield blog.callRemote("wp.newPost",
                0, # Blog ID
                user, # Username
                passwd, # Password
                { # Content
                    "post_type": "post",
                    "post_status": "publish",
                    "comment_status": "open",
                    "post_title": title.encode("utf8"),
                    "post_content": "{}<br><br><a href=\"{}\">Torrent</a>{}".format(img, info_link, comment),
                    "terms_names": {"category": categories}
                }
            )
        except Exception as e:
            if retries:
                self.master.modules["irc"].msg(u"#commie-staff", u"Failed to make blog post ({}), retrying in a minute. This was attempt #{:,d}".format(title, retries))
            raise e

        try:
            data = yield blog.callRemote("wp.getPost", 0, user, passwd, int(post_id))
        except:
            link = "<unknown url>"
        else:
            link = data["link"]

        if retries:
            self.master.modules["irc"].msg(u"#commie-staff", u"Created blog post ({}): {}".format(title, link))
        returnValue(link)
开发者ID:Haidaraaaaa,项目名称:Servrhe,代码行数:55,代码来源:blog.py

示例4: render_GET

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def render_GET(self, request):
     key = request.args.get('key', [None])[0]
     if key is None or key != xml_key:
         return "fail"
     proxy = Proxy(xml_source)
     op = request.args.get('op', [None])[0]
     if op is not None:
         if op == 'store':
             proxy.callRemote(xml_method, xml_login, xml_password).addCallbacks(self.storeDocs, self.pr)
         elif op == 'compare' or op == 'update':
             proxy.callRemote(xml_method, xml_login, xml_password).addCallbacks(self.compareDocs, self.pr)
         elif op == 'descr':
             print "try to store"
             self.storeDescription(request)
     return "ok"
开发者ID:mysoftpro,项目名称:pc,代码行数:17,代码来源:catalog.py

示例5: playMusic

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
def playMusic():
    if request.method == 'POST':
        form=request.form
        tag =  [form.get(val) for val in ['tag']]
        print tag

        api=API8tracks(config.api_8tracks)

        mixset = api.mixset(tags=tag, sort='popular')
        print mixset
        url= "http://streamTaMaman.wav" # [stream.data['track_file_stream_url'] for stream in mixset.mixes[0].tracks_cache]
        proxy = Proxy('http://'+str(config.main_server.ip)+':'+str(config.main_server.rpc_port))
        proxy.callRemote('raspi.find_music_url',0,url).addCallbacks(return_value)
        reactor.run()
        # TODO : this is blocking, warning!!
    return json.dumps("haha")
开发者ID:gabadie,项目名称:GHome,代码行数:18,代码来源:run.py

示例6: uploadImage

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
    def uploadImage(self, name, data):
        exception = self.master.modules["commands"].exception

        user = yield self.config.get("user")
        passwd = yield self.config.get("pass")
        if user is None or passwd is None:
            raise exception(u"No blog username or password in config")

        blog = Proxy("http://commiesubs.com/xmlrpc.php")
        blog.queryFactory.noisy = False

        try:
            data = yield blog.callRemote("wp.uploadFile",
                0, # Blog ID
                user, # Username
                passwd, # Password
                { # Content
                    "name": name,
                    "type": "image/jpeg",
                    "bits": xmlrpclib.Binary(data),
                    "overwrite": True
                }
            )
        except:
            raise exception(u"Couldn't upload image")

        returnValue(data["url"])
开发者ID:Haidaraaaaa,项目名称:Servrhe,代码行数:29,代码来源:blog.py

示例7: _callRemote

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def _callRemote(self, method, *args, **kwds):
     proxy = Proxy("http://%s/XMLRPC" % self.host, user=self.username,
         password=self.password, allowNone=True)
     deferred = proxy.callRemote(method, *args, **kwds)
     deferred.addCallbacks(self.onResult, self.onError)
     deferred.addCallbacks(self._stopReactor, self._stopReactor)
     reactor.run()
     return 0
开发者ID:DSDev-NickHogle,项目名称:terane,代码行数:10,代码来源:commands.py

示例8: run

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def run(self):
     proxy = Proxy("http://%s/XMLRPC" % self.host, user=self.username,
         password=self.password, allowNone=True)
     deferred = proxy.callRemote('iterEvents', self.query, None, self.indices,
         self.limit, self.reverse, self.fields)
     deferred.addCallback(self.printResult)
     deferred.addErrback(self.printError)
     reactor.run()
     return 0
开发者ID:DSDev-NickHogle,项目名称:terane,代码行数:11,代码来源:searcher.py

示例9: reload

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def reload(self):
     if self._deferred != None:
         self._deferred.cancel()
     self._results.clear()
     proxy = Proxy(self._url, user=self._user, password=self._pass, allowNone=True)
     self._deferred = proxy.callRemote('iter', self._query)
     self._deferred.addCallback(self._getResult)
     self._deferred.addErrback(self._getError)
     logger.debug("searching with query '%s'" % self._query)
开发者ID:DSDev-NickHogle,项目名称:terane,代码行数:11,代码来源:search.py

示例10: modifyDB

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def modifyDB(self, ret, cmd, *params):
     abspath = os.path.join(self.shell._path(self.workingDirectory).path, params[0])
     import re
     abspath = re.sub(r'\\+', '/', abspath)
     def printValue(value):
         pass
     from twisted.web.xmlrpc import Proxy
     try:
         proxy = Proxy('http://localhost:80/rpc/')
         if cmd == 'del':
             method = 'deleted'
         elif cmd == 'stor':
             method = 'uploaded'
         else:
             print "unexpected db operation"
             return ret
         proxy.callRemote(method, self.portal.realm.username, abspath).addCallback(printValue)   
     except Exception, e:
         print e
开发者ID:dalinhuang,项目名称:gybprojects,代码行数:21,代码来源:ftpserver.py

示例11: retryWithOtherProvider

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def retryWithOtherProvider(self, error, nodeConfig, words, docId, filename):
     if self.providerSet:
         nextHost, nextPort = self.providerSet.pop()
         print "[webapp] trying to donwload %r from %s:%s" % (filename, nextHost, nextPort)
         proxy = Proxy(str('http://%s:%s' % (nextHost, nextPort)))
         d = proxy.callRemote('downloadFile', docId, words)
         d.addCallback(self.gotDataBack, nodeConfig, filename, words)
         d.addErrback(self.retryWithOtherProvider, nodeConfig, words, docId, filename)
         return d
     else:
         return self.onDownloadFileError('no provider available', filename)
开发者ID:BackupTheBerlios,项目名称:maay-svn,代码行数:13,代码来源:webapplication.py

示例12: Tailer

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
class Tailer(Window):
    def __init__(self, args):
        title = "Tail '%s'" % args
        self._query = args
        self._lastId = None
        self._results = ResultsListbox()
        self.interval = 2
        self._url = "http://%s/XMLRPC" % console.host
        self._user = console.username
        self._pass = console.password
        self._delayed = None
        self._deferred = None
        logger.debug("using proxy url %s" % self._url)
        Window.__init__(self, title, self._results)

    def startService(self):
        Window.startService(self)
        logger.debug("started tail: using query '%s'" % self._query)
        self._proxy = Proxy(self._url, user=self._user, password=self._pass, allowNone=True)
        self._tail()

    def stopService(self):
        if self._delayed != None:
            self._delayed.cancel()
        self._delayed = None
        if self._deferred != None:
            self._deferred.cancel()
        self._deferred = None
        logger.debug("stopped tail")
        Window.stopService(self)

    def _tail(self):
        self._deferred = self._proxy.callRemote('tailEvents', self._query, self._lastId)
        self._deferred.addCallback(self._getResult)
        self._deferred.addErrback(self._getError)

    @useMainThread
    def _getResult(self, results):
        """
        Append each search result into the ResultsListbox.
        """
        try:
            meta = results.pop(0)
            self._lastId = meta['lastId']
            logger.debug("tail returned %i results, last id is %s" % (len(results), self._lastId))
            if len(results) > 0:
                for evid,defaultfield,defaultvalue,fields in results:
                    evid = EVID(evid[0], evid[1])
                    self._results.append(evid, defaultfield, defaultvalue, fields)
                console.redraw()
            from twisted.internet import reactor
            self._delayed = reactor.callLater(self.interval, self._tail)
        except Exception, e:
            logger.exception(e)
开发者ID:msfrank,项目名称:terane,代码行数:56,代码来源:tail.py

示例13: test_inbound_request_and_reply

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
    def test_inbound_request_and_reply(self):
        address = self.transport.xmlrpc_server.getHost()
        url = 'http://' + address.host + ':' + str(address.port) + '/foo/'
        proxy = Proxy(url)
        x = proxy.callRemote('handleUSSD', {
            'TransactionId': '0001',
            'USSDServiceCode': '543',
            'USSDRequestString': '14321*1000#',
            'MSISDN': '275551234',
            'USSDEncoding': 'GSM0338',      # Optional
            'TransactionTime': '2013-07-05T22:58:47.565596'
            })
        [msg] = yield self.tx_helper.wait_for_dispatched_inbound(1)
        expected_inbound_payload = {
            'message_id': '',
            'content': None,
            'from_addr': '',    # msisdn
            'to_addr': '',      # service code
            'session_event': TransportUserMessage.SESSION_RESUME,
            'transport_name': self.tx_helper.transport_name,
            'transport_type': 'ussd',
            'transport_metadata': {
                'mtn_rwanda_ussd': {
                    'transaction_id': '0001',
                    'transaction_time': '2013-07-05T22:58:47.565596',
                },
            },
        }
        yield self.assert_inbound_message(
            expected_inbound_payload,
            msg,
            from_addr='275551234',
            to_addr='543',
            session_event=TransportUserMessage.SESSION_NEW)

        expected_reply = {'MSISDN': '275551234',
                          'TransactionId': '0001',
                          'TransactionTime': datetime.now().isoformat(),
                          'USSDEncoding': 'GSM0338',
                          'USSDResponseString': 'Test message',
                          'USSDServiceCode': '543',
                          'action': 'end'}

        self.tx_helper.make_dispatch_reply(
            msg, expected_reply['USSDResponseString'], continue_session=False)

        received_text = yield x
        for key in received_text.keys():
            if key == 'TransactionTime':
                self.assertEqual(len(received_text[key]),
                        len(expected_reply[key]))
            else:
                self.assertEqual(expected_reply[key], received_text[key])
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:55,代码来源:test_mtn_rwanda_ussd.py

示例14: start

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def start(self):
     proxy = Proxy("http://beatty.userland.com/RPC2")
     if TEST_ERRORS:
         i = self.i
         if i == 3:
             proxy = Proxy("http://illegal-host_name/")
         elif i == 6:
             proxy = Proxy("http://beatty.userland.com/")
         elif i == 8:
             proxy = Proxy("http://beatty.userland.com/testing_xmlrpc_error_case")
         
     return proxy.callRemote('examples.getStateName', self.i)
开发者ID:bhramoss,项目名称:code,代码行数:14,代码来源:recipe-203471.py

示例15: relayAnswer

# 需要导入模块: from twisted.web.xmlrpc import Proxy [as 别名]
# 或者: from twisted.web.xmlrpc.Proxy import callRemote [as 别名]
 def relayAnswer(self, answer, local=False): # local still unused
     """record and forward answers to a query.
     If local is True, then the answers come from a local query,
     and thus must not be recorded in the database"""
     print "P2pQuerier relayAnswer : %s documents" % len(answer.documents)
     query = self._receivedQueries.get(answer.queryId)
     if query:
         print " ... relaying Answer to originator ..."
     else:
         query = self._sentQueries.get(answer.queryId)
         if query:
             print " ... originator : we got mail :) ... "
         else:
             print " ... bailing out (bug?) : we had no query for this answer"
             return
     
     toSend = []
     
     for document in answer.documents:
         if not isinstance(document, dict):
             document = document.__dict__
         # TODO: record answer in database if local is False
         # auc : to cache them ?
         if not query.isKnown(document):
             abstract = makeAbstract(document['text'], query.getWords())
             document['text'] = untagText(removeSpace(abstract))
             query.addMatch(document)
             #toSend.append(document.asDictionnary())
             # above was meant to be like .asKwargs() ?
             # anyway, this stuff is xmlrpc-serializable (auc)
             toSend.append(document)
     
     if query.sender != self.nodeId: 
         try:
             # getNodeUrl seems not to exist yet
             #senderUrl = self.querier.getNodeUrl(query.sender)
             host = query.host 
             port = query.port
             print " ... will send answer to %s:%s" % (host, port)
             senderUrl = 'http://%s:%s' % (host, port)
             proxy = Proxy(senderUrl)
             d = proxy.callRemote('distributedQueryAnswer',
                                  query.qid,
                                  self.nodeId,
                                  toSend)
             d.addCallback(self.querier.registerNodeActivity)
             d.addErrback(P2pErrbacks.answerQueryProblem)
             P2pErrbacks.setAnswerTarget(senderUrl)
         except ValueError:
             print "unknown node %s" % query.sender
     else: # local would be true ? don't waste the answers ...
         self._notifyAnswerCallbacks(answer.queryId, toSend)
开发者ID:BackupTheBerlios,项目名称:maay-svn,代码行数:54,代码来源:p2pquerier.py


注:本文中的twisted.web.xmlrpc.Proxy.callRemote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。