def main(domain, python_version, nuke): domain = ensure_domain(domain) project = Project(domain, python_version) project.sanity_checks(nuke=nuke) project.virtualenv.create(nuke=nuke) project.create_webapp(nuke=nuke) project.add_static_file_mappings() project.webapp.reload() print( snakesay( dedent(''' All done! - Your site is now live at https://{domain} - Your web app config screen is here: https://www.pythonanywhere.com/user/{username}/webapps/{mangled_domain} '''.format(domain=domain, username=getpass.getuser().lower(), mangled_domain=domain.replace('.', '_')))))
def main(domain, django_version, python_version, nuke): domain = ensure_domain(domain) project = DjangoProject(domain, python_version) project.sanity_checks(nuke=nuke) project.create_virtualenv(django_version, nuke=nuke) project.run_startproject(nuke=nuke) project.find_django_files() project.update_settings_file() project.run_collectstatic() project.create_webapp(nuke=nuke) project.add_static_file_mappings() project.update_wsgi_file() project.webapp.reload() print( snakesay('All done! Your site is now live at https://{domain}'.format( domain=domain)))
def delete_logs( domain_name: str = typer.Option( "your-username.pythonanywhere.com", "-d", "--domain", help="Domain name, eg www.mydomain.com", ), log_type: LogType = typer.Option( LogType.all, "-t", "--log-type", ), log_index: str = typer.Option( "all", "-i", "--log-index", callback=index_callback, help= "0 for current log, 1-9 for one of archive logs or all for all of them", ), ): webapp = Webapp(ensure_domain(domain_name)) log_types = ["access", "error", "server"] logs = webapp.get_log_info() if log_type == "all" and log_index == "all": for key in log_types: for log in logs[key]: webapp.delete_log(key, log) elif log_type == "all": for key in log_types: webapp.delete_log(key, int(log_index)) elif log_index == "all": for i in logs[log_type]: webapp.delete_log(log_type, int(i)) else: webapp.delete_log(log_type, int(log_index)) typer.echo(snakesay("All done!"))
def test_custom_domain_remains_unchanged(self): custom_domain = "foo.bar.baz" result = ensure_domain(custom_domain) assert result == custom_domain