def mods_install():
    i = 0
    progress_bar.Update(i, visible=True)
    output.Update(visible=True)
    for ID in data['files']:
        # parsing the url
        url = url_parse(ID['projectID'], ID['fileID'])

        file_name = os.path.basename(url.strip("'")).replace("%20", " ")

        if os.path.exists(os.getcwd() + '\\' + file_name):
            print("Skipping " + file_name + " because File already exists!")
        else:
            print("Downloading: " + file_name)
            requests.download(url, file_name)
        i = i + 500 / len(data['files'])
        window.Refresh()
        progress_bar.Update(i)
Exemplo n.º 2
0
print(
    requests.post2str("http://httpbin.org/post",
                      """{"foo": "bar", "baz": true}""")
)  # HTTP POST data only to string response.

print(
    requests.post2dict("http://httpbin.org/post",
                       """{"foo": "bar", "baz": true}""")
)  # HTTP POST data only to dictionary response.

print(
    requests.post2json(
        "http://httpbin.org/post",
        """{"foo": "bar", "baz": true}"""))  # HTTP POST data to JSON response.

print(requests.download("http://httpbin.org/image/jpeg",
                        "foo.jpeg"))  # HTTP GET Download 1 file.

print(requests.get2str2(["http://httpbin.org/json", "http://httpbin.org/xml"
                         ]))  # HTTP GET body to string from a list.

print(
    requests.download2([
        ("http://httpbin.org/image/jpeg",
         "foo.jpg"),  # HTTP GET Download a list of files.
        ("http://httpbin.org/image/svg", "bar.svg")
    ]))

requests.set_headers([("key", "value")])  # Set HTTP Headers example.

requests.debugConfig()  # Debug the internal Configuration.
Exemplo n.º 3
0
 def test_download(self):
     self.assertIsNone(
         faster_than_requests.download("http://httpbin.org/image/jpeg",
                                       "foo.jpeg"))