Skip to content

Commit 86df831

Browse files
authored
Merge branch 'master' into master
2 parents cd54cbe + a77f077 commit 86df831

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pythonanywhere/api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,23 @@
2222
class AuthenticationError(Exception):
2323
pass
2424

25+
class NoTokenError(Exception):
26+
pass
2527

2628
def 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

3133
def 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,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
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/',

0 commit comments

Comments
 (0)