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


Python xmlrpclib.Binary方法代码示例

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


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

示例1: terminate_proc

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def terminate_proc(self, argv):
        try:
            (ptype, val) = argv.split(' ')
            # ptype = '/PID' if ptype == 'pid' else '/IM'
            # cmd = 'cmd.exe /c taskkill %s %s' % (ptype, val)
            # log = 'cmd.log'
            # p = subprocess.Popen(cmd, stdout=file(log, 'w'), stderr=subprocess.STDOUT)
            # p.wait()
            # data = self.__read_file(log)
            # https://www.cnblogs.com/xjh713/p/6306587.html?utm_source=itdadao&utm_medium=referral
            if sys.platform == 'win32':
                ptype = '/PID' if ptype == 'pid' else '/IM'
                data = os.popen('taskkill %s %s' % (ptype, val)).read()
            else:
                os.kill(val, signal.SIGKILL)
            return (True, xmlrpclib.Binary(data))
        except Exception as e:
            return (False, str(e)) 
开发者ID:anhkgg,项目名称:PyRat,代码行数:20,代码来源:pyratcli.py

示例2: main

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def main(options, args):
    address = "%s://%s:%s@%s:%s%s" % (PROTOCOL, options.username, options.password,
            options.server, options.port, ENDPOINT)
    print "Connecting to: %s" % hidepassword(address)
    
    server = xmlrpclib.ServerProxy(address, verbose=VERBOSE)
    
    try:
        plugin_id, version_id = server.plugin.upload(xmlrpclib.Binary(open(args[0]).read()))
        print "Plugin ID: %s" % plugin_id
        print "Version ID: %s" % version_id
    except xmlrpclib.ProtocolError, err:
        print "A protocol error occurred"
        print "URL: %s" % hidepassword(err.url, 0)
        print "HTTP/HTTPS headers: %s" % err.headers
        print "Error code: %d" % err.errcode
        print "Error message: %s" % err.errmsg 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:19,代码来源:plugin_upload.py

示例3: __init__

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def __init__(self, source, instance_only=False):
        self.instance_only = instance_only
        with TemporaryDirectory() as tempdir:
            self.source = source
            self.tempdir = tempdir
            if self.is_http:
                self.filename = Package._download(self.source, self.tempdir)
            else:
                self.filename = os.path.basename(self.source)
                copyfile(os.path.expanduser(self.source), os.path.join(self.tempdir, self.filename))
            self.path = os.path.join(self.tempdir, self.filename)
            with open(self.path, 'rb') as f:
                self.body = xmlrpclib.Binary(f.read())
            self._extract_files()
            self._parse_metadata() 
开发者ID:cloudblue,项目名称:apsconnect-cli,代码行数:17,代码来源:package.py

示例4: xmlrpc_run

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def xmlrpc_run(self, port=24444, bind='127.0.0.1', logRequests=False):
        '''Run xmlrpc server'''
        import umsgpack
        from pyspider.libs.wsgi_xmlrpc import WSGIXMLRPCApplication
        try:
            from xmlrpc.client import Binary
        except ImportError:
            from xmlrpclib import Binary

        application = WSGIXMLRPCApplication()

        application.register_function(self.quit, '_quit')
        application.register_function(self.size)

        def sync_fetch(task):
            result = self.sync_fetch(task)
            result = Binary(umsgpack.packb(result))
            return result
        application.register_function(sync_fetch, 'fetch')

        def dump_counter(_time, _type):
            return self._cnt[_time].to_dict(_type)
        application.register_function(dump_counter, 'counter')

        import tornado.wsgi
        import tornado.ioloop
        import tornado.httpserver

        container = tornado.wsgi.WSGIContainer(application)
        self.xmlrpc_ioloop = tornado.ioloop.IOLoop()
        self.xmlrpc_server = tornado.httpserver.HTTPServer(container, io_loop=self.xmlrpc_ioloop)
        self.xmlrpc_server.listen(port=port, address=bind)
        logger.info('fetcher.xmlrpc listening on %s:%s', bind, port)
        self.xmlrpc_ioloop.start() 
开发者ID:binux,项目名称:pyspider,代码行数:36,代码来源:tornado_fetcher.py

示例5: main

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def main(parameters, arguments):
    """Main entry point.

    :param parameters: Command line parameters.
    :param arguments: Command line arguments.
    """
    address = "%s://%s:%s@%s:%s%s" % (
        PROTOCOL,
        parameters.username,
        parameters.password,
        parameters.server,
        parameters.port,
        ENDPOINT)
    print "Connecting to: %s" % hide_password(address)

    server = xmlrpclib.ServerProxy(address, verbose=VERBOSE)

    try:
        plugin_id, version_id = server.plugin.upload(
            xmlrpclib.Binary(open(arguments[0]).read()))
        print "Plugin ID: %s" % plugin_id
        print "Version ID: %s" % version_id
    except xmlrpclib.ProtocolError, err:
        print "A protocol error occurred"
        print "URL: %s" % hide_password(err.url, 0)
        print "HTTP/HTTPS headers: %s" % err.headers
        print "Error code: %d" % err.errcode
        print "Error message: %s" % err.errmsg 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:30,代码来源:plugin_upload.py

示例6: addTorrent

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def addTorrent(self, torrent, uris=None, options=None, position=None):
        '''
        This method adds BitTorrent download by uploading ".torrent" file.
        torrent: string, torrent file path
        uris: list, list of webseed URIs
        options: dict, additional options
        position: integer, position in download queue
        return: This method returns GID of registered download.
        '''
        return self.server.aria2.addTorrent(xmlrpclib.Binary(open(torrent, 'rb').read()), uris, options, position) 
开发者ID:abbeyokgo,项目名称:PyOne,代码行数:12,代码来源:aria2.py

示例7: addMetalink

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def addMetalink(self, metalink, options=None, position=None):
        '''
        This method adds Metalink download by uploading ".metalink" file.
        metalink: string, metalink file path
        options: dict, additional options
        position: integer, position in download queue
        return: This method returns list of GID of registered download.
        '''
        return self.server.aria2.addMetalink(xmlrpclib.Binary(open(metalink, 'rb').read()), options, position) 
开发者ID:abbeyokgo,项目名称:PyOne,代码行数:11,代码来源:aria2.py

示例8: add

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def add(self, media, filepath, overwrite=True):
        """Set *media* from local file *filepath*. *overwrite* parameter specify
        if the media must be overwrite if it exists remotely.
        """
        with open(filepath, 'rb') as fhandler:
            self._dokuwiki.send('wiki.putAttachment', media,
                                Binary(fhandler.read()), ow=overwrite) 
开发者ID:fmenabe,项目名称:python-dokuwiki,代码行数:9,代码来源:dokuwiki.py

示例9: set

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def set(self, media, _bytes, overwrite=True, b64encode=False):
        """Set *media* from *_bytes*. *overwrite* parameter specify if the media
        must be overwrite if it exists remotely.
        """
        data = base64.b64encode(_bytes) if b64encode else Binary(_bytes)
        self._dokuwiki.send('wiki.putAttachment', media, data, ow=overwrite) 
开发者ID:fmenabe,项目名称:python-dokuwiki,代码行数:8,代码来源:dokuwiki.py

示例10: test_default

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def test_default(self):
        t = xmlrpclib.Binary()
        self.assertEqual(str(t), '') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_xmlrpc.py

示例11: test_string

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def test_string(self):
        d = '\x01\x02\x03abc123\xff\xfe'
        t = xmlrpclib.Binary(d)
        self.assertEqual(str(t), d) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xmlrpc.py

示例12: test_decode

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def test_decode(self):
        d = '\x01\x02\x03abc123\xff\xfe'
        de = base64.encodestring(d)
        t1 = xmlrpclib.Binary()
        t1.decode(de)
        self.assertEqual(str(t1), d)

        t2 = xmlrpclib._binary(de)
        self.assertEqual(str(t2), d) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例13: upload_file

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def upload_file():
	with open(filepath, "rb") as handle:
		binary_data = xmlrpclib.Binary(handle.read())
	proxy.server_receive_file(filename,binary_data) 
开发者ID:iandouglas96,项目名称:piPrint,代码行数:6,代码来源:piPrintControl.py

示例14: attach_file

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def attach_file(server, token, space, title, files):
    existing_page = server.confluence1.getPage(token, space, title)

    for filename in files.keys():
        try:
            server.confluence1.removeAttachment(token, existing_page["id"], filename)
        except Exception as e:
            logging.exception("Skipping %s exception in removeAttachment" % e)
        content_types = {
            "gif": "image/gif",
            "png": "image/png",
            "jpg": "image/jpeg",
            "jpeg": "image/jpeg",
        }
        extension = os.path.spl(filename)[1]
        ty = content_types.get(extension, "application/binary")
        attachment = {"fileName": filename, "contentType": ty, "comment": files[filename]}
        f = open(filename, "rb")
        try:
            byts = f.read()
            logging.info("calling addAttachment(%s, %s, %s, ...)", token, existing_page["id"], repr(attachment))
            server.confluence1.addAttachment(token, existing_page["id"], attachment, xmlrpclib.Binary(byts))
            logging.info("done")
        except Exception:
            logging.exception("Unable to attach %s", filename)
        finally:
            f.close() 
开发者ID:pycontribs,项目名称:confluence,代码行数:29,代码来源:confluence.py

示例15: getPdf

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Binary [as 别名]
def getPdf(self,aMsg):
    c = canvas.Canvas(None)
    c.drawString(100,100,aMsg)
    c.showPage()
    c.save()
    return xmlrpclib.Binary(c.getpdfdata()) 
开发者ID:ActiveState,项目名称:code,代码行数:8,代码来源:recipe-413404.py


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