-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (19 loc) · 556 Bytes
/
utils.py
File metadata and controls
23 lines (19 loc) · 556 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import requests
import uuid
import sys
import re
import builtins
def downloadImageFromUrl(url, path):
if not url.startswith('http'):
return None
img_data = requests.get(url).content
fPath = path + '/' + str(uuid.uuid1()) + '.jpg'
with open(fPath, 'wb') as handler:
handler.write(img_data)
return fPath
def print(ftext, **args):
if sys.stdout.isatty():
builtins.print(ftext, flush=True, **args)
else:
builtins.print(re.sub(r'\33\[\d+m', ' ', ftext), flush=True, **args)