77from typing import Any
88
99from dateutil .parser import parse
10- from snakesay import snakesay
1110
1211from pythonanywhere_core .base import call_api , get_api_endpoint , PYTHON_VERSIONS
13- from pythonanywhere_core .exceptions import SanityException , PythonAnywhereApiException
12+ from pythonanywhere_core .exceptions import SanityException , PythonAnywhereApiException , MissingCNAMEException
1413
1514
1615class Webapp :
@@ -54,7 +53,6 @@ def sanity_checks(self, nuke: bool) -> None:
5453
5554 :raises SanityException: if API token is missing or webapp already exists
5655 """
57- print (snakesay ("Running API sanity checks" ))
5856 token = os .environ .get ("API_TOKEN" )
5957 if not token :
6058 raise SanityException (
@@ -127,24 +125,13 @@ def add_default_static_files_mappings(self, project_path: Path) -> None:
127125 def reload (self ) -> None :
128126 """Reload webapp
129127
128+ :raises MissingCNAMEException: if CNAME not found (reload succeeded)
130129 :raises PythonAnywhereApiException: if API call fails"""
131130 url = f"{ self .domain_url } reload/"
132131 response = call_api (url , "post" )
133132 if not response .ok :
134133 if response .status_code == 409 and response .json ()["error" ] == "cname_error" :
135- print (
136- snakesay (
137- dedent (
138- """
139- Could not find a CNAME for your website. If you're using an A record,
140- CloudFlare, or some other way of pointing your domain at PythonAnywhere
141- then that should not be a problem. If you're not, you should double-check
142- your DNS setup.
143- """
144- )
145- )
146- )
147- return
134+ raise MissingCNAMEException ()
148135 raise PythonAnywhereApiException (f"POST to reload webapp via API failed, got { response } :{ response .text } " )
149136
150137 def set_ssl (self , certificate : str , private_key : str ) -> None :
@@ -155,7 +142,6 @@ def set_ssl(self, certificate: str, private_key: str) -> None:
155142
156143 :raises PythonAnywhereApiException: if API call fails
157144 """
158- print (snakesay (f"Setting up SSL for { self .domain } via API" ))
159145 url = f"{ self .domain_url } ssl/"
160146 response = call_api (url , "post" , json = {"cert" : certificate , "private_key" : private_key })
161147 if not response .ok :
@@ -193,12 +179,6 @@ def delete_log(self, log_type: str, index: int = 0) -> None:
193179
194180 :raises PythonAnywhereApiException: if API call fails
195181 """
196- if index :
197- message = f"Deleting old (archive number { index } ) { log_type } log file for { self .domain } via API"
198- else :
199- message = f"Deleting current { log_type } log file for { self .domain } via API"
200- print (snakesay (message ))
201-
202182 if index == 1 :
203183 suffix = ".1"
204184 elif index > 1 :
0 commit comments