marksml commited on
Commit
d6ecec3
·
1 Parent(s): a643a03

download files directly into files-folder

Browse files
files/1f975693-876d-457b-a649-393859e79bf3.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:200f767e732b49efef5c05d128903ee4d2c34e66fdce7f5593ac123b2e637673
3
+ size 280868
files/7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:196b64ea8f72841cb0c4fc972ca82a28e74de926c402bb043305e12e05e012b7
3
+ size 5285
files/99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b218c951c1f888f0bbe6f46c080f57afc7c9348fffc7ba4da35749ff1e2ac40f
3
+ size 179304
files/cca530fc-4052-43b2-b130-b30968d8aa44.png ADDED

Git LFS Details

  • SHA256: daaa417b9746471ec313c3233bb63175908d49de0859b5bce99431392e45efd8
  • Pointer size: 130 Bytes
  • Size of remote file: 63.1 kB
files/f918266a-b3e0-4914-865d-4faa564f1aef.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from random import randint
2
+ import time
3
+
4
+ class UhOh(Exception):
5
+ pass
6
+
7
+ class Hmm:
8
+ def __init__(self):
9
+ self.value = randint(-100, 100)
10
+
11
+ def Yeah(self):
12
+ if self.value == 0:
13
+ return True
14
+ else:
15
+ raise UhOh()
16
+
17
+ def Okay():
18
+ while True:
19
+ yield Hmm()
20
+
21
+ def keep_trying(go, first_try=True):
22
+ maybe = next(go)
23
+ try:
24
+ if maybe.Yeah():
25
+ return maybe.value
26
+ except UhOh:
27
+ if first_try:
28
+ print("Working...")
29
+ print("Please wait patiently...")
30
+ time.sleep(0.1)
31
+ return keep_trying(go, first_try=False)
32
+
33
+ if __name__ == "__main__":
34
+ go = Okay()
35
+ print(f"{keep_trying(go)}")
tools.py CHANGED
@@ -34,10 +34,8 @@ def fetch_file(api_url:str, task_id: str, file_name: str) -> None:
34
  file_url = f"{api_url}/files/{task_id}"
35
  downsloads_dir = "files"
36
  os.makedirs(downsloads_dir, exist_ok=True)
37
- local_path = os.path.join(downsloads_dir, task_id)
38
- os.makedirs(local_path, exist_ok=True)
39
-
40
- file_path = os.path.join(local_path, file_name)
41
  if not os.path.exists(file_path):
42
  print(f"Downloading file {file_name} for task {task_id} ...")
43
  file_response = requests.get(file_url, timeout=30)
 
34
  file_url = f"{api_url}/files/{task_id}"
35
  downsloads_dir = "files"
36
  os.makedirs(downsloads_dir, exist_ok=True)
37
+
38
+ file_path = os.path.join(downsloads_dir, file_name)
 
 
39
  if not os.path.exists(file_path):
40
  print(f"Downloading file {file_name} for task {task_id} ...")
41
  file_response = requests.get(file_url, timeout=30)