Spaces:
Sleeping
Sleeping
Oleg Shulyakov
commited on
Commit
·
d9e2874
1
Parent(s):
3c74dbc
Extract login error
Browse files
app.py
CHANGED
@@ -20,21 +20,21 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
20 |
DOWNLOAD_FOLDER = "./downloads"
|
21 |
OUTPUT_FOLDER = "./outputs"
|
22 |
|
|
|
|
|
23 |
def create_folder(folder_name: str):
|
24 |
if not os.path.exists(folder_name):
|
25 |
print(f"Creating folder: {folder_name}")
|
26 |
os.makedirs(folder_name)
|
27 |
|
28 |
-
def
|
29 |
if oauth_token is None or oauth_token.token is None:
|
30 |
-
|
31 |
|
32 |
try:
|
33 |
whoami(oauth_token.token)
|
34 |
except Exception as e:
|
35 |
-
|
36 |
-
|
37 |
-
return True
|
38 |
|
39 |
# escape HTML for logging
|
40 |
def escape(s: str) -> str:
|
@@ -329,9 +329,7 @@ def process_model(
|
|
329 |
split_max_size: str | None,
|
330 |
oauth_token: gr.OAuthToken | None,
|
331 |
):
|
332 |
-
|
333 |
-
if is_valid_token(oauth_token) is False:
|
334 |
-
raise gr.Error("You must be logged in to use GGUF-my-repo")
|
335 |
|
336 |
token = oauth_token.token
|
337 |
print(f"Current working directory: {os.path.abspath(os.getcwd())}")
|
@@ -587,7 +585,7 @@ with gr.Blocks(css=css) as demo:
|
|
587 |
#####
|
588 |
# Layout
|
589 |
#####
|
590 |
-
gr.Markdown(
|
591 |
gr.LoginButton(min_width=250)
|
592 |
|
593 |
gr.HTML("<h1 style=\"text-aling:center;\">Create your own GGUF Quants!</h1>")
|
|
|
20 |
DOWNLOAD_FOLDER = "./downloads"
|
21 |
OUTPUT_FOLDER = "./outputs"
|
22 |
|
23 |
+
ERROR_LOGIN = "You must be logged in to use GGUF-my-repo."
|
24 |
+
|
25 |
def create_folder(folder_name: str):
|
26 |
if not os.path.exists(folder_name):
|
27 |
print(f"Creating folder: {folder_name}")
|
28 |
os.makedirs(folder_name)
|
29 |
|
30 |
+
def validate_token(oauth_token):
|
31 |
if oauth_token is None or oauth_token.token is None:
|
32 |
+
raise gr.Error(ERROR_LOGIN)
|
33 |
|
34 |
try:
|
35 |
whoami(oauth_token.token)
|
36 |
except Exception as e:
|
37 |
+
raise gr.Error(ERROR_LOGIN)
|
|
|
|
|
38 |
|
39 |
# escape HTML for logging
|
40 |
def escape(s: str) -> str:
|
|
|
329 |
split_max_size: str | None,
|
330 |
oauth_token: gr.OAuthToken | None,
|
331 |
):
|
332 |
+
validate_token(oauth_token)
|
|
|
|
|
333 |
|
334 |
token = oauth_token.token
|
335 |
print(f"Current working directory: {os.path.abspath(os.getcwd())}")
|
|
|
585 |
#####
|
586 |
# Layout
|
587 |
#####
|
588 |
+
gr.Markdown(ERROR_LOGIN)
|
589 |
gr.LoginButton(min_width=250)
|
590 |
|
591 |
gr.HTML("<h1 style=\"text-aling:center;\">Create your own GGUF Quants!</h1>")
|