def local_spy(project_name, module_name, filepath): print("local_spyspy", project_name, module_name, filepath) try: code_file = DS.get_file_contents(project_name, module_name, filepath) code_str = dcd(str.encode(code_file.content)).decode("utf-8") except UnknownObjectException as _: # code_str = "# File not found" raise HTTPError(404) return code_str
def gamer_save(): codename, code = request.json['codename'], request.json['code'] # codename, code = request.query['codename'], request.query['code'] project, *moduler = codename.split('/') filename = "/".join(moduler) code = dcd(str.encode(code)).decode("utf-8") try: code_status = DS.save_file(project, filename, code) except Exception as err: code_status = "Fail saving {}: {}".format(filename, err) return code_status
def _gamer_claim(projecter, moduler=""): form_values = "author_nick author_name author_email author_org author_site author_public".split() code = {key: request.params[key] for key in form_values} key = str(uuid.uuid4())[:8] spy = str({key: code}).replace("'", '"')[1:-1] + ",[\n" # coded = str(code).replace("'", '"') author_index = projecter if moduler else '_spy' filename = "{}/__score__.py".format(moduler) if moduler else "__score__.py" code_status = '' try: print("_gamer_claimtry", author_index, projecter, filename, spy) code_status = DS.append_file(author_index, filename, "],\n"+spy) except Exception as err: print("_gamer_claimexcept", code_status, err) if "404" in str(err): try: print("_gamer_claimif 404 ", author_index, projecter, filename, spy) code_status += DS.create_file(author_index, filename, "{\n"+spy) except Exception as err: code_status = "Fail creating {}: {}, {}".format(filename, str(err), code_status) print("Play _gamer_claim Exception", code_status, err) return code_status
def _gamer_claim(projecter, moduler=""): modl, namel = projecter if moduler else '_spy', "__author__.py" form_values = "author_nick author_name author_email author_org author_site author_public".split( ) code = {key: request.params[key] for key in form_values} key = moduler if moduler else projecter spy = str({key: code}).replace("'", '"')[1:-1] + ",\n" # coded = str(code).replace("'", '"') author_index = projecter if moduler else '_spy' action = "/supygirls/gamer/{}/".format(projecter) claim = "{}/".format(projecter) if moduler else "" filename = "{}/__author__.py".format( moduler) if moduler else "__author__.py" try: print(author_index, projecter, filename, spy) code_status = DS.append_file(author_index, filename, spy) filename = '{}/__author__.py'.format( moduler) if moduler else '__author__.py' code_status += DS.create_file(projecter, filename, "{\n" + spy) print(code, filename) code_file = DS.get_file_contents(modl, '', namel) code = "{" + dcd(str.encode( code_file.content)).decode("utf-8")[1:-2] + "}" code = json.loads(code) cenas = [(girl, code[girl.lower()]['author_nick'] if girl.lower() in code else 'livre') for girl in GIRLS] except Exception as err: code_status = "Fail creating {}: {}".format(filename, err) cenas = [(girl, 'livre') for girl in GIRLS] return dict(pagetitle="SuPyGirls - {}".format(projecter), title=projecter, action=action, claim=claim, image="garden.jpg", cenas=cenas, status=code_status)
def modulerr(name): modl, namel = name, "__author__.py" try: code_file = DS.get_file_contents(modl, '', namel) code = "{" + dcd(str.encode( code_file.content)).decode("utf-8")[1:-2] + "}" code = json.loads(code) cenas = [(girl, code[girl.lower()]['author_nick'] if girl.lower() in code else 'livre') for girl in GIRLS] except Exception as err: cenas = [(girl, 'livre') for girl in GIRLS] return dict(pagetitle="SuPyGirls - {}".format(name), title=name, action="/supygirls/gamer/{}/".format(name), claim="{}/".format(name), image="garden.jpg", cenas=cenas)
def gamer(mod, name): modl, namel = mod.lower(), name.lower() try: code_file = DS.get_file_contents(modl, namel) code = code_file.content # code = dcd(str.encode(code_file.content)).decode("utf-8") except Exception as err: code = "# " + ".".join([modl, namel, "main.py"]) code = ecd(bytearray(code.encode("UTF8"))).decode("utf-8") print("Play gamer Exception", code, err) return dict( pagetitle='PLAY - SuPyGirls - {} - {}'.format(mod.capitalize(), name.capitalize()), title=name, modText=mod.capitalize(), nameText=name.capitalize(), image="supygirls_logo.png", mod=mod.replace(',', '_').lower(), code=code, brython_css=CSS, brython_js=JS, menu=[m.split(",") for m in MENU.split(":")])
def project(): modl, namel = "_spy", "__author__.py" try: code_file = DS.get_file_contents(modl, '', namel) code = "{" + dcd(str.encode( code_file.content)).decode("utf-8")[1:-2] + "}" # print('/supygirls/project ', code) code = json.loads(code) cenas = [(girl, code[girl.lower()]['author_nick'] if girl.lower() in code else 'livre') for girl in CGIRLS] except Exception as err: cenas = [(girl, 'livre') for girl in CGIRLS] # print('/supygirls/project ', err) return dict(pagetitle="SuPyGirls", action="/supygirls/moduler/", claim="", title="SUPYGIRLS", image="miro.jpg", cenas=cenas)