File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 2222class AuthenticationError (Exception ):
2323 pass
2424
25+ class NoTokenError (Exception ):
26+ pass
2527
2628def get_api_endpoint (flavour = "webapps" ):
2729 domain = os .environ .get ('PYTHONANYWHERE_DOMAIN' , 'pythonanywhere.com' )
2830 return 'https://www.{domain}/api/v0/user/{{username}}/{flavour}/' .format (domain = domain , flavour = flavour )
2931
3032
3133def call_api (url , method , ** kwargs ):
32- token = os .environ ['API_TOKEN' ]
34+ token = os .environ .get ('API_TOKEN' )
35+ if token is None :
36+ raise NoTokenError (
37+ "Oops, you don't seem to have an API token. "
38+ "Please go to the 'Account' page on PythonAnywhere, then to the 'API Token' "
39+ "tab. Click the 'Create a new API token' button to create the token, then "
40+ "start a new console and try running this script again."
41+ )
3342 insecure = os .environ .get ('PYTHONANYWHERE_INSECURE_API' ) == 'true'
3443 response = requests .request (
3544 method = method ,
Original file line number Diff line number Diff line change 99
1010setup (
1111 name = 'pythonanywhere' ,
12- version = '0.3 ' ,
12+ version = '0.5 ' ,
1313 description = 'PythonAnywhere helper tools for users' ,
1414 long_description = long_description ,
1515 url = 'https://github.com/pythonanywhere/helper_scripts/' ,
You can’t perform that action at this time.
0 commit comments