def init(): try: raw_input(""" i don't recognize you, stranger. let's make friends. press <enter> to begin, or <ctrl-c> to get out of here. """) except KeyboardInterrupt: print("\n\nthanks for checking in! i'll always be here.\n\n") quit() users = open(USERFILE, 'a') users.write(USER+"\n") users.close() subprocess.call(["mkdir", PATH]) subprocess.call(["mkdir", CONFIG]) subprocess.call(["mkdir", DATA]) header = gen_header() headerfile = open(os.path.join(CONFIG, "header.txt"), 'w') for line in header: headerfile.write(line) headerfile.close() subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG]) setup() #subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), WWW]) core.load() raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n") return ""
def init(): ''' new user creation * introduces user * calls setup functinos ''' try: raw_input(""" i don't recognize you, stranger. let's make friends. press <enter> to begin, or <ctrl-c> to get out of here. """) except KeyboardInterrupt: print("\n\nthanks for checking in! i'll always be here.\n\n") quit() ## record user in source list users = open(USERFILE, 'a') users.write(USER + "\n") users.close() ## make .ttbp directory structure subprocess.call(["mkdir", PATH]) subprocess.call(["mkdir", CONFIG]) subprocess.call(["mkdir", DATA]) versionFile = os.path.join(PATH, "version") open(versionFile, "w").write(__version__) ## create header file header = gen_header() headerfile = open(os.path.join(CONFIG, "header.txt"), 'w') for line in header: headerfile.write(line) headerfile.close() ## copy footer and default stylesheet subprocess.call([ "cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG ]) subprocess.call([ "cp", os.path.join(SOURCE, "config", "defaults", "style.css"), CONFIG ]) ## run user-interactive setup and load core engine setup() core.load(SETTINGS) #raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n") return ""
def main(): core.load() commit_info = get_commit_info() log('info', "Starting at [{}] {}: {}".format(commit_info['id'], commit_info['author'], commit_info['message'])) register_tasks() workers.register_workers() site_id = get_site_id(core.config.site) log('debug', "Fetched site ID {} from {}".format(site_id, core.config.site)) core.config.site_id = site_id core.obj.post_storage = PostStorage("posts.db") core.worker.sews.start() core.worker.scanner.start() core.worker.handler.start()
def check_init(): global SETTINGS print("\n\n") if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")): print(chatter.say("greet")+", "+USER+".") while not os.path.isfile(TTBPRC): setup_handler() try: SETTINGS = json.load(open(TTBPRC)) except ValueError: setup_handler() raw_input("\n\npress <enter> to explore your feels.\n\n") core.load() return "" else: return init()
def init(): ''' new user creation * introduces user * calls setup functinos ''' try: raw_input(""" i don't recognize you, stranger. let's make friends. press <enter> to begin, or <ctrl-c> to get out of here. """) except KeyboardInterrupt: print("\n\nthanks for checking in! i'll always be here.\n\n") quit() ## record user in source list users = open(USERFILE, 'a') users.write(USER+"\n") users.close() ## make .ttbp directory structure subprocess.call(["mkdir", PATH]) subprocess.call(["mkdir", CONFIG]) subprocess.call(["mkdir", DATA]) ## create header file header = gen_header() headerfile = open(os.path.join(CONFIG, "header.txt"), 'w') for line in header: headerfile.write(line) headerfile.close() ## copy footer and default stylesheet subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG]) subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), CONFIG]) ## run user-interactive setup and load core engine setup() core.load(SETTINGS) raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n") return ""
def check_init(): ''' user handler * checks for presence of ttbprc * checks for last run version ''' global SETTINGS print("\n\n") if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")): print(chatter.say("greet")+", "+USER+".\n") ''' ## ttbprc validation while not os.path.isfile(TTBPRC): setup_repair() try: SETTINGS = json.load(open(TTBPRC)) except ValueError: setup_repair() ''' ## ttbp env validation if not valid_setup(): setup_repair() ## version checker mismatch = build_mismatch() if mismatch is not False: switch_build(mismatch) if not updated(): update_version() ## when ready, enter main program and load core engine raw_input("press <enter> to explore your feels.\n\n") core.load(SETTINGS) return "" else: return init()
def update_publishing(): ''' updates publishing directory if user is publishing. otherwise, wipe it. ''' global SETTINGS if core.publishing(): oldDir = SETTINGS.get("publish dir") newDir = select_publish_dir() SETTINGS.update({"publish dir": newDir}) if oldDir: subprocess.call(["rm", os.path.join(PUBLIC, oldDir)]) make_publish_dir(newDir) core.load_files() core.write("index.html") else: unpublish() SETTINGS.update({"publish dir": None}) core.load(SETTINGS)
from flask import Flask from flask import request import core net = core.load()["net"] app = Flask(__name__) @app.route("/") def hello(): seed = request.args.get('seed', 'The ') n = int(request.args.get('n', "200")) return net.predict(seed, seq_len=n)
def main_menu(): ''' main navigation menu ''' menuOptions = [ "record your feels", "review your feels", "check out your neighbors", "browse global feels", "scribble some graffiti\t(new!)", "change your settings", "send some feedback", "see credits", "read documentation"] print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n\n") util.print_menu(menuOptions, RAINBOW) try: choice = raw_input("\ntell me about your feels (or 'quit' to exit): ") except KeyboardInterrupt: redraw(EJECT) return main_menu() if choice == '0': redraw() today = time.strftime("%Y%m%d") write_entry(os.path.join(DATA, today+".txt")) core.www_neighbors() elif choice == '1': redraw("your recorded feels, listed by date:\n") view_feels(USER) elif choice == '2': users = core.find_ttbps() redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:\n") view_neighbors(users) elif choice == '3': redraw("most recent global entries\n") view_feed() elif choice == '4': graffiti_handler() elif choice == '5': redraw("now changing your settings. press <ctrl-c> if you didn't mean to do this.") try: core.load(setup()) # reload settings to core except KeyboardInterrupt(): redraw(EJECT) redraw() elif choice == '6': redraw("you're about to send mail to ~endorphant about ttbp\n") feedback_menu() elif choice == '7': redraw() show_credits() elif choice == '8': subprocess.call(["lynx", os.path.join(SOURCE, "..", "README.html")]) redraw() elif choice in QUITS: return stop() else: redraw(INVALID) return main_menu()
from core import load net = load()["net"] print(net.predict("The "))
def main_menu(): ''' main navigation menu ''' menuOptions = [ "record your feels", "review your feels", "check out your neighbors", "browse global feels", "scribble some graffiti\t(new!)", "change your settings", "send some feedback", "see credits", "read documentation"] print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n") util.print_menu(menuOptions, RAINBOW) try: choice = raw_input("\ntell me about your feels (or 'quit' to exit): ") except KeyboardInterrupt: redraw(EJECT) return main_menu() if choice == '0': redraw() today = time.strftime("%Y%m%d") write_entry(os.path.join(DATA, today+".txt")) core.www_neighbors() elif choice == '1': if core.publishing(): intro = "here are some options for reviewing your feels:" redraw(intro) review_menu(intro) core.load_files() core.write("index.html") else: redraw("your recorded feels, listed by date:") view_feels(USER) elif choice == '2': users = core.find_ttbps() redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:") view_neighbors(users) elif choice == '3': redraw("most recent global entries") view_feed() elif choice == '4': graffiti_handler() elif choice == '5': redraw("now changing your settings. press <ctrl-c> if you didn't mean to do this.") try: core.load(setup()) # reload settings to core except KeyboardInterrupt(): redraw(EJECT) redraw() elif choice == '6': redraw("you're about to send mail to ~endorphant about ttbp") feedback_menu() elif choice == '7': redraw() show_credits() elif choice == '8': subprocess.call(["lynx", os.path.join(SOURCE, "..", "README.html")]) redraw() elif choice in QUITS: return stop() else: redraw(INVALID) return main_menu()
#!/usr/bin/python import core core.load() print("\n blog updated at "+core.write("index.html")+"\n")
#!/usr/bin/python import core core.load() print("\n blog updated at " + core.write("index.html") + "\n")
def test_core(): core.load() assert core.config.write_key == "(((write_key)))" assert core.config.write_token == "(((write_token)))"
from flask import Flask from core import load app = Flask(__name__) container = load(app) if __name__ == '__main__': app.run(port=8080)
import core from matplotlib import pyplot as plt if __name__ == "__main__": inp, re = core.load( "/home/martin/Desktop/arm/train/merged_norm/train/image_0.png") # check loaded objects plt.figure() plt.imshow(inp / 255.) plt.figure() plt.imshow(re / 255.) plt.show() # random crop the images plt.figure(figsize=(6, 6)) for i in range(0): rj_inp, rj_re = core.random_jitter(inp, re) plt.subplot(2, 2, i + 1) plt.imshow(rj_inp / 255.0) plt.axis('off')