def main(): """Main function""" args = parse_args() obj = Facade(args.file_name) obj.get_page_contents_with_page_num(1) tables = obj.show_tables() print("Tables are: %s" % tables)
def appApi(): #Get clientRequest JSON to Dict clientRequest = request.get_json(force=True) #Send Facade facade = Facade(clientRequest) #Return Facade return jsonify( facade.serverResponse()), facade.serverResponse()['status_code']
def __init__(self, fname_in, fname_out): """Create the Plot object. Args: fname_in: model input text file fname_out: model output (results) text file """ # parent handles the initialization Facade.__init__(self, fname_in, fname_out) self.__button = None # matplotlib Button to open output file
def __test(): """ Test function for debugging work. Do not use. """ addpath = set_common_path('C:\\Users\\adminuser\\Dropbox\\cbd\\') fac = Facade(addpath('ini.txt', True), addpath('output.txt')) fac.trace('debug')
def __init__(self, parent=None): super(TaskDlg, self).__init__() self.facade = Facade() self.setupUi(self) self.facade = Facade() self.thread = FacadeThread(self.facade) self.thread.sinOutProductList.connect(self.onProductLoad) self.thread.sinOutNotifyMany.connect(self.onProductChecked) self.thread.sinOutNotifyFinish.connect(self.resetControl) self.controls = [] self.controlMap = {} self.isNotified = True
def test_facade_create_cooker(self): facade = Facade(test_cooker1, test_cooker2) unknown_cooker1 = facade.cooker1 unknown_cooker2 = facade.cooker2 self.assertEqual(unknown_cooker1.name, test_cooker1.name) self.assertEqual(unknown_cooker2.name, test_cooker2.name)
def appLogin(): if request.method == 'POST': email = request.form['email'] senha = request.form['senha'] clientRequest = { 'function': 'confirmAuth', 'email': email, 'senha': senha } facade = Facade(clientRequest) user = facade.serverResponse() if user['status'] == True: return render_template("app.html", user=user['data']) else: return render_template("login.html") else: return render_template("login.html")
def generarReporte(request): fechaInicio = request.POST.get('fechaInicio','') fechaFin = request.POST.get('fechaFin','') alcance = request.POST.get('alcance','') share = request.POST.get('shares','') reacciones = request.POST.get('reacciones','') likes = request.POST.get('likes','') love = request.POST.get('love','') haha = request.POST.get('haha','') wow = request.POST.get('wow','') sad = request.POST.get('sad','') angry = request.POST.get('angry','') correo = request.POST.get('correo','') config = open("configuracion.txt","w") config.write("inicio "+fechaInicio+"\n") config.write("fin "+fechaFin+"\n") config.write("formula "+str(int(alcance)/10.0)+"\n") config.write("formula "+str(int(share)/10.0)+"\n") config.write("formula "+str(int(reacciones)/10.0)+"\n") config.write("formula "+str(int(likes)/100.0)+"\n") config.write("formula "+str(int(love)/100.0)+"\n") config.write("formula "+str(int(haha)/100.0)+"\n") config.write("formula "+str(int(wow)/100.0)+"\n") config.write("formula "+str(int(sad)/100.0)+"\n") config.write("formula "+str(int(angry)/100.0)+"\n") config.write("correos "+correo) config.close() facade = Facade() facade.generarReporte() return redirect('/')
def handle_payment(self, order_number, total, **kwargs): stripe_ref = Facade().charge( order_number, total, card=self.request.POST[STRIPE_TOKEN], description=self.payment_description(order_number, total, **kwargs), metadata=self.payment_metadata(order_number, total, **kwargs)) source_type, __ = SourceType.objects.get_or_create(name=PAYMENT_METHOD_STRIPE) source = Source( source_type=source_type, currency=settings.STRIPE_CURRENCY, amount_allocated=total.incl_tax, amount_debited=total.incl_tax, reference=stripe_ref) self.add_payment_source(source) self.add_payment_event(PAYMENT_EVENT_PURCHASE, total.incl_tax)
def __init__(self): """Constructor.""" self._parser = self._build_parser() self._facade = Facade() self._config = ConfigManager()
class CommandUI(object): """Handles commands.""" def __init__(self): """Constructor.""" self._parser = self._build_parser() self._facade = Facade() self._config = ConfigManager() @staticmethod def _build_parser(): """Build parser.""" parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(help='commands', dest='command') parser_add = subparsers.add_parser('add', help='add a new file') parser_add.add_argument('name', nargs='+', help='file name') parser_add.add_argument('-c', '--category', type=str, required=True, help='file\'s category') parser_add.add_argument('-d', '--description', nargs='+', help='file\'s extended description') parser_add.add_argument('-t', '--tags', type=str, nargs='+', help='file\'s tags') parser_rm = subparsers.add_parser('rm', help='rm a file') parser_rm.add_argument('file_id', type=int, help='file id') parser_mod = subparsers.add_parser('mod', help='modify a file') parser_mod.add_argument('file_id', type=int, help='file id') parser_mod.add_argument('-n', '--name', nargs='+', help='file name') parser_mod.add_argument('-c', '--category', type=str, help='file\'s category') parser_mod.add_argument('-d', '--description', nargs='+', help='file\'s extended description') parser_mod.add_argument('-t', '--tags', type=str, nargs='+', help='file\'s tags') parser_sql = subparsers.add_parser('sql', help='type custom sql') parser_sql.add_argument('sql', type=str, help='sql query') parser_sql.add_argument('-s', '--select', action="store_true", help='is a select query') parser_find = subparsers.add_parser('find', help='find files') parser_find.add_argument('-n', '--name', nargs='+', help='file name') parser_find.add_argument('-c', '--category', type=str, help='file\'s category') parser_find.add_argument('-d', '--description', nargs='+', help='file\'s extended description') parser_find.add_argument('-t', '--tags', type=str, nargs='+', help='file\'s tags') parser_find.add_argument('-j', '--json', action="store_true", help='export json') subparsers.add_parser('init', help='initial db setup') parser_show = subparsers.add_parser('show', help='show file info') parser_show.add_argument('file_id', type=int, help='file id') return parser def test_parser(self, test_args=None): """Test parser.""" args = self._control(self._parser.parse_args(args=test_args)) return args def parse_args(self): """Call Facades function based on args..""" args = self._control(self._parser.parse_args()) if args.command == "add": self._facade.add_file(args.name, args.category, args.description, args.tags) elif args.command == "rm": self._facade.rm_file(args.file_id) elif args.command == "mod": optional_args = [args.name, args.category, args.description, args.tags] if all(v is None for v in optional_args): exit("ERROR: provide at least one argument to modify.") else: self._facade.mod_file(args.file_id, args.name, args.category, args.description, args.tags) elif args.command == "sql": result = self._facade.execute(args.sql, args.select) if result: rst_json = json.loads(result) print(format_dict_list(rst_json)) elif args.command == "find": result = self._facade.find_file(args.name, args.category, args.description, args.tags) if args.json: print(result) else: rst_json = json.loads(result) if rst_json: print(format_dict_list(rst_json)) else: exit("No results.") elif args.command == "init": if self._facade.init(): print("Database created in: " + self._config.database_path) else: exit("Database already exists in: " + self._config.database_path) elif args.command == "show": result = self._facade.get_info(args.file_id) rst_json = json.loads(result) if rst_json: for key in rst_json: print("{}: {}".format(key, rst_json[key])) else: exit("File with id {} doesn't exist.".format(args.file_id)) def _control(self, args): """Parse lists to strings. With this we don't have to surround arguments in quotes. This: box add file long name -c something -d this is a description Instead of: box add "long name" -c something -d "this is a description" """ if args.command in ["add", "mod", "find"]: if args.name: args.name = " ".join(args.name) if args.description: args.description = " ".join(args.description) return args
def draw(self): Facade.draw(self) from visible import Window self.textSurface = Window.instance.resources.font_provider.render( text=self.text) self.size = self.textSurface.get_size()
3D printer error detection application. This is the main entry for the application. This application is part of a bachelor thesis project at NTNU Ålesund Department of ICT and Natural Sciences. Developed and written by Tomas Paulsen. RUN: On Raspberry pi set "useRPI" flag to True On PC set "useRPI" flag to False Run main.py to start Usage: On Raspberry pi a physical button should be used to trigger gathering of images. On PC a key button is used to trigger gathering of images. Start camera page. Apply mask. Set HSV threshold values and morphological operations. Apply Save Masked Images. Start monitoring 3D print. The application alert if error is detected. """ from GUI import MainWindow from facade import Facade useRPi = True facade = Facade(useRPi=useRPi) GUIApplication = MainWindow(facade=facade) GUIApplication.start()
from flask import Flask, render_template, request, make_response from jinja2 import Template from facade import Facade, VkAudioFacade, WeatherFacade, RatesFacade import config app = Flask(__name__) config = config.load_config('config.json') facade = Facade(config) vk_audio_facade = VkAudioFacade(config) weather_facade = WeatherFacade(config) rates_facade = RatesFacade(config) @app.route("/") def home(): data = __get_template_data() return render_template("home.html", currency_rate=data['currency_rate'], forecast=data['forecast'], date_formatted=facade.get_date_formatted()) @app.route("/search", methods=['POST', 'GET']) def search(): if request.method == 'GET': data = __get_template_data() resp = make_response(render_template("search.html", currency_rate=data['currency_rate'], forecast=data['forecast'])) if config.user_id is not None: resp.set_cookie('vkUserId', str(config.user_id)) return resp if request.method == 'POST': query = request.form['query'] offset = request.form['offset']
def render(self, surface): Facade.render(self, surface) if (self.visible): surface.blit(self.textSurface, self.position)
def login(email: str, password: str): user = Facade.login(email, password) if user == None: return redirect('/login/') session['email'] = user.email return redirect('/login/')
from facade import Facade from important_stuff import ImportantStuff from more_important_stuff import MoreImportantStuff facade_runner = Facade() facade_runner.doStuff() # can also give facade created objects important_stuff = ImportantStuff() more_important_stuff = MoreImportantStuff() facade_runner_2 = Facade(important_stuff, more_important_stuff) facade_runner_2.doStuff()
# !/usr/bin/env python # -*- coding:utf8 -- from facade import Facade f = Facade('mnasperu') print f.make_sence()
def facade(): return Facade()
from facade import Facade if __name__ == "__main__": facade = Facade() facade.run()
# !/usr/bin/env python # -*- coding:utf8 -- from facade import Facade f = Facade('mnasperu') print f.make_sence()
def signup(email: str, password: str): if Facade.signup(email, password): return redirect('/login/') else: flash('failed') return redirect('/signup/')
def __init__(self, text="label"): Facade.__init__(self) self.text = text self.textSurface = None
def main(): facade = Facade() facade.run()
def main(): """ Main entry point for the program. # Returns int: Error codes ```text 0 = no error 1 = error during model operation (e.g., simulation run) (exception errors) 2 = error in commandline flags/options ``` """ # create the following commandline options: # [-h] -i [-e -m [...]] [-p] [-o [-n | -a]] maingrp = argparse.ArgumentParser( add_help=False) # avoid multiple provisions of help rungrp = argparse.ArgumentParser(add_help=False) # model run option metgrp = argparse.ArgumentParser( add_help=False) # weather statistics option netgrp = argparse.ArgumentParser(add_help=False) # network graph option parser = argparse.ArgumentParser( parents=[maingrp]) # help provided only by this level mainman = maingrp.add_argument_group('required arguments') # required flags: mainman.add_argument('-i', required=True, metavar='filename', help='path and filename for model initialization') mainman.add_argument('-o', required=True, metavar='filename', help='path and filename for output') # optional flags: maingrp.add_argument('-e', required='-m' in sys.argv, metavar='workbook', help='path and filename of Excel workbook') maingrp.add_argument( '-m', required='-e' in sys.argv, nargs='+', metavar=('macro', 'args'), help='name of Excel VBA macro, followed by its arguments, if any') maingrp.add_argument('-p', action='store_true', help=argparse.SUPPRESS) # daily model run flag: rungrp.add_argument('-n', metavar='days', type=int, help='number of simulation days to run the model') # weather statistics flag: metgrp.add_argument('-a', action='store_true', help='append to existing weather statistics file') subparsers = parser.add_subparsers(dest='mode') subparsers.add_parser('run', parents=[maingrp, rungrp]) # inherit the options subparsers.add_parser('met', parents=[maingrp, metgrp]) subparsers.add_parser('net', parents=[maingrp, netgrp]) args = parser.parse_args() if len(sys.argv) == 1: printmsg([__doc__]) return 2 try: if args.mode == 'run': fac = Facade(args.i, args.o) fac.run_simulation(True if args.n else False, args.n) elif args.mode == 'met': fac = Facade(args.i, '') # output file not needed since no simulation runs fac.output_weather_stats(args.o, args.a) elif args.mode == 'net': outfile = '~temp~.txt' # temporary output file just for tracing the program flow fac = Facade(args.i, outfile) fac.trace(args.o) os.remove( outfile) # done tracing, so delete the temporary output file # check if calling an Excel macro is requested: if args.e and args.m: macroname = args.m[0] # name of Excel VBA macro/subroutine macroargs = args.m[1:] # VBA macro/subroutine arguments, if any Facade.runxlmacro(args.e, macroname, *macroargs) except (ArithmeticError, Exception) as e: printmsg(['\n', str(e), 'Aborting.'], printtrace=True, wait=args.p) return 1 return 0
from facade import Facade if __name__ == "__main__": facade = Facade() print facade.get_forecast('London','UK')
def build_only_sauce_pizza(self) -> None: self.builder.produce_dough() self.builder.produce_sauce() self.notify(self._finish_pizza_observer) def build_full_pizza(self) -> None: self.builder.produce_dough() self.builder.produce_sauce() self.builder.produce_topping() self.notify(self._finish_pizza_observer) def notify(self, observer: PizzaObserver) -> None: print("Наблюдатель говорит:") observer.update(self) if __name__ == "__main__": director1 = Cook("NewCook1", None, None) builder1 = SpicyPizzaBuilder() director1.builder = builder1 director2 = Cook("NewCook2", None, None) builder2 = HawaiianPizzaBuilder() director2.builder = builder2 cookers = Facade(director1, director2) cookers.cooke1_operation() cookers.cooker2_operation()