File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1616from ctfcli .cli .pages import PagesCommand
1717from ctfcli .cli .plugins import PluginsCommand
1818from ctfcli .cli .templates import TemplatesCommand
19- from ctfcli .core .exceptions import MissingAPIKey , ProjectNotInitialized
19+ from ctfcli .core .exceptions import (
20+ MissingAPIKey ,
21+ MissingInstanceURL ,
22+ ProjectNotInitialized ,
23+ )
2024from ctfcli .core .plugins import load_plugins
2125from ctfcli .utils .git import check_if_dir_is_inside_git_repo
2226
@@ -148,6 +152,10 @@ def main():
148152 if isinstance (ret , int ):
149153 sys .exit (ret )
150154
155+ except MissingInstanceURL as e :
156+ click .secho (e , fg = "red" )
157+ sys .exit (1 )
158+
151159 except MissingAPIKey as e :
152160 click .secho (e , fg = "red" )
153161 sys .exit (1 )
Original file line number Diff line number Diff line change 33from requests import Session
44
55from ctfcli .core .config import Config
6- from ctfcli .core .exceptions import MissingAPIKey
6+ from ctfcli .core .exceptions import MissingAPIKey , MissingInstanceURL
77
88
99class API (Session ):
1010 def __init__ (self ):
1111 config = Config ()
1212
1313 # Load required configuration values
14- self .url = config ["config" ]["url" ]
14+ try :
15+ self .url = config ["config" ]["url" ]
16+ except KeyError :
17+ raise MissingInstanceURL ()
1518
1619 try :
1720 self .access_token = config ["config" ]["access_token" ]
Original file line number Diff line number Diff line change 66class MissingAPIKey (Exception ):
77 def __str__ (self ):
88 return (
9- "Missing API key. Please set the API key in your configuration file or set CTFCLI_ACCESS_TOKEN environment variable."
9+ "Missing API key. "
10+ "Please set the API key in your configuration file or set the CTFCLI_ACCESS_TOKEN environment variable."
11+ )
12+
13+
14+ class MissingInstanceURL (Exception ):
15+ def __str__ (self ):
16+ return (
17+ "Missing CTFd instance URL. "
18+ "Please set the instance URL in your configuration file or set the CTFCLI_URL environment variable."
1019 )
1120
1221
You can’t perform that action at this time.
0 commit comments