當前位置: 首頁>>代碼示例>>Python>>正文


Python restfulie.Restfulie類代碼示例

本文整理匯總了Python中restfulie.Restfulie的典型用法代碼示例。如果您正苦於以下問題:Python Restfulie類的具體用法?Python Restfulie怎麽用?Python Restfulie使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Restfulie類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

    def setUp(self):
        self.video_granulate_service = Restfulie.at("http://localhost:8885/").auth('test', 'test').as_('application/json')
        self.sam = Restfulie.at("http://localhost:8888/").auth('test', 'test').as_('application/json')
        self.uid_list = []

        input_video = open(join(FOLDER_PATH,'input','working_google.flv')).read()
        self.b64_encoded_video = b64encode(input_video)
開發者ID:nsi-iff,項目名稱:videogranulate_buildout,代碼行數:7,代碼來源:testVideoGranulate.py

示例2: testAuthentication

    def testAuthentication(self):
        """ Test if the server is authenticating correctly """
        sam_with_non_existing_user = Restfulie.at("http://localhost:8888/").as_("application/json").auth('dont', 'exists')
        result = sam_with_non_existing_user.post(value='test')
        self.assertEquals(result.code, "401")

        sam_with_non_existing_user = Restfulie.at("http://localhost:8888/").as_("application/json").auth('test', 'wrongpassword')
        result = sam_with_non_existing_user.post(value='test')
        self.assertEquals(result.code, "401")
開發者ID:nsi-iff,項目名稱:sam_buildout,代碼行數:9,代碼來源:testSAM.py

示例3: setUp

    def setUp(self):
        self.video_convert_service = Restfulie.at("http://localhost:8884/").auth('test', 'test').as_('application/json')
        self.sam = Restfulie.at("http://localhost:8888/").auth('test', 'test').as_('application/json')
        self.uid_list = []

        input_video = open(join(FOLDER_PATH,'input','rubik.flv')).read()
        self.b64_encoded_video = b64encode(input_video)
        response = self.video_convert_service.post(video=self.b64_encoded_video, filename='video1.flv', callback='http://localhost:8887/').resource()
        self.video_key = response.key
        self.uid_list.append(self.video_key)
開發者ID:nsi-iff,項目名稱:videoconvert_buildout,代碼行數:10,代碼來源:testPerformanceVideoConvert.py

示例4: test_extraction_with_document_stored_in_SAM

 def test_extraction_with_document_stored_in_SAM(self):
     pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
     pdf64 = b64encode(pdf)
     sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
     resource = sam.put(value={'file':pdf64, 'filename':'teste.pdf'}).resource()
     doc_key = resource.key
     service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
     response = service.post(doc_key=doc_key, filename='teste.pdf')
     sleep(5)
     response = service.get(key=doc_key, metadata=True).resource()
     metadata_key = response.metadata_key
     metadata_key |should_not| equal_to(None)
開發者ID:nsi-iff,項目名稱:metadataservice_buildout,代碼行數:12,代碼來源:testMetadataService.py

示例5: it_should_allow_posting_as_xml

 def it_should_allow_posting_as_xml(self):
     uri = 'http://coolresource/post-here'
     content = {'item': {'name': 'something'}}
     encoded_content = Dummy()
     with Stub() as urlencode:
         from urllib import urlencode
         urlencode({'content': "<item><name>something</name></item>"}) >> encoded_content
     with Mock() as urlopen:
         from urllib2 import urlopen
         urlopen(uri, encoded_content)
     Restfulie.at(uri).as_('application/xml').post(content)
     urlopen.validate()
開發者ID:viniciuschagas,項目名稱:restfulie-python,代碼行數:12,代碼來源:entry_point_post_spec.py

示例6: test_callback_extraction_service

 def test_callback_extraction_service(self):
     pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
     pdf64 = b64encode(pdf)
     pdf64 = "dasdasih"
     sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
     resource = sam.put(value={'file':pdf64, 'filename':'teste.pdf'}).resource()
     doc_key = resource.key
     service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
     response = service.post(doc_key=doc_key, filename='teste.pdf', callback_url='http://localhost:8886/', verb='POST')
     sleep(3)
     callback_log = open('/home/joao/git/metadataservice_buildout/twistd.log').read()
     (doc_key in callback_log) |should| equal_to(True)
開發者ID:nsi-iff,項目名稱:metadataservice_buildout,代碼行數:12,代碼來源:testMetadataService.py

示例7: it_should_allow_posting_as_json

 def it_should_allow_posting_as_json(self):
     uri = 'http://coolresource/post-here'
     content = {"just": "testing"}
     encoded_content = Dummy()
     with Mock() as dumps:
         from json import dumps
         dumps(content) >> encoded_content
     with Mock() as urlopen:
         from urllib2 import urlopen
         urlopen(uri, encoded_content)
     Restfulie.at(uri).as_('application/json').post(content)
     urlopen.validate()
     dumps.validate()
開發者ID:viniciuschagas,項目名稱:restfulie-python,代碼行數:13,代碼來源:entry_point_post_spec.py

示例8: it_should_allow_posting_as_xml

 def it_should_allow_posting_as_xml(self):
     uri = 'http://coolresource/post-here'
     content = 'some content'
     encoded_content = Dummy()
     with Mock() as urlencode:
         from urllib import urlencode
         urlencode({'content': content}) >> encoded_content
     with Mock() as urlopen:
         from urllib2 import urlopen
         urlopen(uri, encoded_content)
     Restfulie.at(uri).as_('application/xml').post(content)
     urlencode.validate()
     urlopen.validate()
開發者ID:elesbom,項目名稱:restfulie-python,代碼行數:13,代碼來源:entry_point_post_spec.py

示例9: test_extraction_with_parameter_metadata

    def test_extraction_with_parameter_metadata(self):
        pdf = open(join(FOLDER_PATH, 'teste.pdf')).read()
        pdf64 = b64encode(pdf)
        service = Restfulie.at("http://localhost:8887/").auth('test', 'test').as_('application/json')
        response = service.post(file=pdf64, filename='test.pdf')
        resource = response.resource()
        resource.doc_key |should_not| equal_to(None)
        
        sleep(5)
        response = service.get(key=resource.doc_key, metadata=True).resource()
        metadata_key = response.metadata_key
        metadata_key |should_not| equal_to(None)

        sam = Restfulie.at('http://0.0.0.0:8888/').auth('test', 'test').as_('application/json')
        resource = sam.get(key=metadata_key).resource()
        resource.data.autor |should| equal_to('Jose')
開發者ID:nsi-iff,項目名稱:metadataservice_buildout,代碼行數:16,代碼來源:testMetadataService.py

示例10: test_restfulie_at

def test_restfulie_at():
    """
    Running Restfulie.at("www.caelum.com.br") should return
    a Request object with this URI
    """

    assert Restfulie.at("www.caelum.com.br")
開發者ID:nsi-iff,項目名稱:restfulie-py,代碼行數:7,代碼來源:restfulie_test.py

示例11: it_should_allow_posting_as_xml

    def it_should_allow_posting_as_xml(self):
        uri = "http://coolresource/post-here"
        content = {"item": {"name": "something"}}
        encoded_content = Dummy()
        with Stub() as urlencode:
            from urllib import urlencode

            urlencode({"content": "<item><name>something</name></item>"}) >> encoded_content
        with Stub() as response:
            response.code >> 200
        with Mock() as urlopen:
            from urllib2 import urlopen

            urlopen(uri, encoded_content) >> response
        Restfulie.at(uri).as_("application/xml").post(content)
        urlopen.validate()
開發者ID:raphaelcastro,項目名稱:restfulie-python,代碼行數:16,代碼來源:entry_point_post_spec.py

示例12: run

 def run(self, url, verb, video_uid):
     try:
         print "Sending callback to %s" % url
         restfulie = Restfulie.at(url).as_('application/json')
         response = getattr(restfulie, verb)(video_key=video_uid, done=False)
     except Exception, e:
         FailCallback.retry(exc=e, countdown=10)
開發者ID:nsi-iff,項目名稱:nsi.videogranulate,代碼行數:7,代碼來源:tasks.py

示例13: run

    def run(self, uid, callback_url, video_link, sam_settings):
        self.callback_url = callback_url
        self.sam = Restfulie.at(sam_settings['url']).auth(*sam_settings['auth']).as_('application/json')
        self.destination_uid = uid
        self.tmp_path = "/tmp/original-%s" % uuid4()
        video_is_converted = False

        if video_link:
            self._download_video(video_link)
        else:
            response = self._get_from_sam(uid)
            self._original_video = response.data.video
            if not hasattr(response, 'converted'):
                video_is_converted = False
            else:
                video_is_converted = response.data.converted

        if not video_is_converted:
            print "Conversion started."
            self._process_video()
            print "Conversion finished."
            if not self.callback_url == None:
                print "Callback task sent."
                send_task('nsivideoconvert.tasks.Callback', args=(callback_url, self.destination_uid), queue='convert',
                          routing_key='convert')
            else:
                print "No callback."
            return self.destination_uid
        else:
            raise VideoException("Video already converted.")
開發者ID:nsi-iff,項目名稱:nsi.videoconvert,代碼行數:30,代碼來源:tasks.py

示例14: it_gets_raw_data_from_an_entry_point

    def it_gets_raw_data_from_an_entry_point(self):
        content = "<item><name>Rich Rock Sunshine</name></item>"
        self.set_server_content(content)

        resource = Restfulie.at(self.content_uri).raw().get()
        resource.response.code |should| be(200)
        resource.response.body |should| equal_to(content)
開發者ID:BecaMotta,項目名稱:restfulie-python,代碼行數:7,代碼來源:entry_point_spec.py

示例15: run

 def run(self, url, verb, doc_uid, **kwargs):
     try:
         print "Sending fail callback to %s" % url
         restfulie = Restfulie.at(url).as_('application/json')
         response = getattr(restfulie, verb.lower())(doc_key=doc_uid, done=False, error=True)
     except Exception, e:
         FailCallback.retry(exc=e, countdown=10)
開發者ID:nsi-iff,項目名稱:nsi.cloudooomanager,代碼行數:7,代碼來源:tasks.py


注:本文中的restfulie.Restfulie類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。