Transformers
Inference Endpoints
pantat88 commited on
Commit
e118367
·
1 Parent(s): 45a9c5a

Delete pantat88.py

Browse files
Files changed (1) hide show
  1. pantat88.py +0 -45
pantat88.py DELETED
@@ -1,45 +0,0 @@
1
- from IPython.core.magic import register_line_magic
2
- from IPython.display import display, HTML
3
- from urllib.parse import urlparse
4
- import subprocess
5
- import os
6
-
7
- @register_line_magic
8
- def say(line):
9
- args = line.split()
10
- msg = " ".join(args[:-1])
11
- color = args[-1]
12
- display(HTML(f"<span style='color:{color};'>{msg}</span>"))
13
-
14
- @register_line_magic
15
- def download(line):
16
- args = line.split()
17
- url, auth = args[0], "-H 'Authorization: Bearer d3bdbbd15377673b43f7ab4b224f2800'" if "civitai.com" in args[0] else ""
18
-
19
- if len(args) == 1:
20
- fc = f"curl -O -J -L {auth} {args[0]}"
21
- fn = os.path.basename(urlparse(args[0]).path)
22
- elif len(args) == 3:
23
- path, fn = args[1], args[2]
24
- fc = f"mkdir -p {path} && cd {path} && curl -J -L {auth} {args[0]} -o {fn}"
25
- elif '/' in args[1] or '~/ ' in args[1]:
26
- path = args[1]
27
- fc = f"mkdir -p {path} && cd {path} && curl -O -J -L {auth} {args[0]}"
28
- fn = os.path.basename(urlparse(args[0]).path)
29
- else:
30
- fn = args[1]
31
- fc = f"curl -J -L {auth} {args[0]} -o {fn}"
32
-
33
- print(f"Downloading: {fn}")
34
-
35
- try:
36
- result = subprocess.run(fc, shell=True, stderr=subprocess.PIPE, text=True, cwd=os.getcwd(), check=True)
37
- print("done")
38
- except subprocess.CalledProcessError as e:
39
- if "curl: (23)" in e.stderr:
40
- print("Error: File exists")
41
- else:
42
- print(e.stderr)
43
- except KeyboardInterrupt:
44
- print("^ Canceled")
45
-