def continueGetAddressPopulations(driver, address_array, radius_array, url, lastX, lastY): continuedX = 0 if lastX > 0: continuedX = lastX - 1 for x in range(continuedX, len(radius_array)): # x+1 = x in excel sheet driver.get(url) for y in range(0, len(address_array)): # y+1 = y in excel sheet address = address_array[y].address populationError.setError(address, radius_array[x], x + 1, y + 1) putRadius(driver, radius_array[x]) success = putAddress(driver, address) if success: population = app(driver) message = "Address: {0:38} | radius: {1:4} | population: {2:10}".format( address, radius_array[x], population) print(message) populationLog.writeToLog(message) populationExcel.updatePopulationForAddress( radius_array[x], y + 1, population) else: message = "Address: {0:38} | radius: {1:q4} | population: {2:10}".format( address, radius_array[x], "NULL") print(message) populationLog.writeToLog(message) populationExcel.updatePopulationForAddress( radius_array[x], y + 1, "ERROR")
def setUp(self): """Define test variables and initialize app.""" self.app = app(config_name="testing") self.client = self.app.test_client self.bucketlist = {'name': 'Go to Borabora for vacation'} # binds the app to the current context with self.app.app_context(): # create all tables db.create_all()
class Usuario(app.db.Model): __tablename__ = 'usuarios' db = app(db) id = db.Column(db.Integer, primary_key=True) nome = db.Column(db.String(64), unique=True) id_cliente = db.Column( db.Integer, db.ForeignKey('clientes.id')) #conferir relacionamento def __repr__(self): return '<Usuario %r>' % self.nome
def setUp(self): self.app=.app(config_name='test'): self.client.post =.app.client(self) self.singup_url ='/mydiary-api/v1/auth/signup' self.login_url ='/mydiary-api/v1/auth/login' self.addEntry_url ='/mydiary-api/v1/auth/edit' self.deleteEntry_url ='/mydiary-api/v1/auth/delete' self.client_signup_auth = {'fname': 'lname' , 'email':'*****@*****.**', 'password': '******'} self.client_login_auth = {'username': '******', 'email':'*****@*****.**', 'password': '******'}
class Site(app.db.Model): __tablename__ = 'sites' db = app(db) id = db.Column(db.Integer, primary_key=True) descricao = db.Column(db.String(64), unique=True) enderecoSite = db.Column(db.String(64), unique=True) palavrasChave = db.Column(db.String(64), unique=True) id_usuarios = db.Column( db.Integer, db.ForeignKey('usuarios.id')) #conferir relacionamento id_clientes = db.Column( db.Integer, db.ForeignKey('clientes.id')) #conferir relacionamento def __repr__(self): return '<Site %r>' % self.descricao
def test_phonon(): from PySide.phonon import Phonon a = app() # http://qt-project.org/doc/qt-4.8/phonon-overview.html#audio url = "z:/Users/jichi/tmp/test.mp3" print os.path.exists(url) mo = Phonon.MediaObject() audioOutput = Phonon.AudioOutput(Phonon.MusicCategory) path = Phonon.createPath(mo, audioOutput) #mo.setCurrentSource(Phonon.MediaSource(url)) mo.setCurrentSource(url) print mo.play() a.exec_()
def test_zunko(): from sakurakit import skpaths path = r'Z:\Local\Windows\Applications\AHS\VOICEROID+\zunko' #skpaths.append_path(path) # crash skpaths.prepend_path(path) from voiceroid.zunko import ZunkoTalk ai = ZunkoTalk() print ai.load() #ai.setVolume(1) t = "hello world" print ai.speak(t) #from PySide.QtCore import QCoreApplication #a = QCoreApplication(sys.argv) a = app() a.exec_()
def test_cc(): from opencc import opencc import config opencc.setdicdir(config.OPENCC_DIC_LOCATION) #t = u"里面" t = u"我方" t = u"轻轻地" #t = opencc.zhs2zht(t) t = opencc.containszhs(t) #t = opencc.zht2tw(t) print t return a = app() from Qt5.QtWidgets import QLabel w = QLabel("%s" % t) w.show() a.exec_()
def test_wmp(): import os from sakurakit import skthreads from sakurakit.skwincom import SkCoInitializer from wmp.wmp import WindowsMediaPlayer #url = "http://translate.google.com/translate_tts?tl=ja&q=hello" url = "http://tts.baidu.com/text2audio?lan=jp&ie=UTF-8&text=hello" #url = "Z:/Users/jichi/tmp/test.mp3" #url = r"Z:\Users\jichi\tmp\test.mp3" #url = "Z:\Users\jichi\tmp\test.mp3" #url = "Z:\\Users\\jichi\\tmp\\test.mp3" print os.path.exists(url) p = WindowsMediaPlayer() def run(): with SkCoInitializer(threading=True): print p.isValid() print p.play(url) os.system("pause") a = app() skthreads.runasync(run) a.exec_()
#print number #print Param + str(number) + " " + "in vmstat" return number def get_list_info(self, infolist): local_device = device() valuelist = [] for i in range(len(infolist)): info = local_device.get_device_info(str(infolist[i])) valuelist.append(str(infolist[i]) + " " + str(info) + " ") return str("".join(valuelist)) if __name__ == '__main__': local_device = device() local_app = app() local_view = view() orig = "without" new = "withpatch" app_list = open("./littleapp.txt").readlines() orig_log = open(orig, "a+") new_log = open(new, "a+") infolist = [ "nr_free_pages", "nr_inactive_anon", "nr_active_anon", "nr_inactive_file", "nr_active_file", "nr_unevictable", "nr_mlock", "nr_anon_pages", "nr_mapped", "nr_file_pages", "compact_migrate_scanned", "compact_isolated", "pgrefill_dma32", "pgrefill_normal", "pgsteral_kswapd_dma32", "pgsteal_kswapd_normal", "pgsteal_direct_dma32", "pgsteal_direct_normal", "pgscan_kswapd_dma32", "pgscan_kswapd_normal", "pgscan_direct_dma32", "pgscan_direct_normal", "slabs_scanned", "unevictable_pgs_munlocked", "MemFree",
def get_app(self): self.app = app() return self.app
def test_output(capsys, app): app() captured = capsys.readouterr() assert "Pepe\nBart\nCesco\nFernando\nLou\nMaria\nPedro\nLebron\nRuth\nSteven\nRuthPedro\n" in captured.out
def setUp(self): self.app = app(TestConfig) db.create_all() self.client = Client(schema) self.user_factory = factories.UserFactory.create_batch(10)
acl.read_acl == AclType.my_algos # True # Update permissions to private nlp_directory.update_permissions(ReadAcl.private) nlp_directory.get_permissions().read_acl == AclType.private # True text_file = "data://eijan/nlp_directory/data2.txt" # Upload local file if client.file(text_file).exists() is False: client.file(text_file).putFile( "/Users/eijan/Documents/zothacks2019/data2.txt") # Download contents of file as a string if client.file(text_file).exists() is True: with open('data2.txt') as json_file: input = json.load(json_file) # Create the algorithm object using the Summarizer algorithm algo = client.algo('matching/DatingAlgorithm/0.1.3') # Pass in input required by algorithm try: # Get the summary result of your file's contents #print(algo.pipe(input).result) f = open('result1.txt', 'w') json.dump(algo.pipe(input).result, f) f.close() app() except Exception as error: # Algorithm error if, for example, the input is not correctly formatted print(error)
def test_all_data_type(capsys, app): app() captured = capsys.readouterr() assert "[[2, 1], {'name': 'juan'}]\n" in captured.out
def test_chat(): a = app() import chatview chatview.manager().showTopic('global') a.exec_()
{% if cookiecutter.create_cli == 'yes' %}from {{ cookiecutter.module_name }}.main import app app(){% else %}from {{ cookiecutter.module_name }}.main import main main(){% endif %}
def setUp(self): self.app = app(TestConfig) db.create_all() self.factory = factories.UserFactory.create() self.client = self.app.test_client
def __init__(self,plugin,data): import imp Controlador.__init__(self,data) self.login=Login(data) import os from modulos.ztec.zred import Headers,gringolizar self.app=None self.model={} self.shortcodes={} import sys self.plugin=plugin self.HEADERS=Headers() l=self.plugin.navegacion if self.data["model"]["main"].update(): for elem in self.data["model"]["main"].obtenerFilas("AdminMenu"): if elem in l: l.remove(elem) for elem2 in l: self.data["model"]["main"].db("AdminMenu").insertar(elem2[0],elem2[1],elem2[2],elem2[3]) self.HEADERS.set_headers({"Content-type":"text/plain\n"}) from modulos.ztec.intervalor.control import generar2 for w in plugin.widgets: if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html"): generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n") elif os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html"): generar2(config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".html",config.base_root+config.plugins_folder+plugin.name+"/widgets/"+w+"/"+w+".py","#!/usr/bin/python\n# -*- coding: utf-8 -*-\n") if self.data["app"]!=None: import app from app import app self.app=app() from settings import config as settings from settings import routes for elem in plugin.modelos: if os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py"): if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py"): self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model( config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem, config.base_root+config.modelos_folder+"request/","user",ext=".py" ) else: print "El modelo: "+elem+" del plugin: "+plugin.name+" no fue encontrado" else: if not os.path.exists(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"): os.mkdir(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/") if os.path.exists(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py"): f=open(config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_struct.py","r") struct=f.read() f.close() f=open(config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem+"_struct.py","w") f.write(struct) f.close() self.model[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+plugin.name+"/modelos/"+elem+"_model.py").model( config.base_root+config.apps_folder+settings.app+"/admin/"+routes.models_folder+"plugins/"+plugin.name+"/"+elem, config.base_root+config.modelos_folder+"request/","user",ext=".py" ) for elem in plugin.shortcodes: self.shortcodes[elem]=imp.load_source(elem+"_model",config.base_root+config.plugins_folder+self.plugin.name+"/shortcodes/"+elem+".py").shortcode(self) self.shortcodes[elem].ruta=self.plugin.__path__+"/widgets/" self.shortcodes[elem].url=config.base_url+config.plugins_folder+"/".join(self.plugin.__path__.split("/")[-2:])+"/widgets/"
import app import os from flask_sqlalchemy import SQLAlchemy app = app(app) basedir = os.path.abspath(os.path.dirname(__file__)) app.config['SQLAlCHEMY_DATABASE_URI'] =\ 'sqlite:///' + os.path.join(basedir, 'data.sqlite') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) class Site(app.db.Model): __tablename__ = 'sites' db = app(db) id = db.Column(db.Integer, primary_key=True) descricao = db.Column(db.String(64), unique=True) enderecoSite = db.Column(db.String(64), unique=True) palavrasChave = db.Column(db.String(64), unique=True) id_usuarios = db.Column( db.Integer, db.ForeignKey('usuarios.id')) #conferir relacionamento id_clientes = db.Column( db.Integer, db.ForeignKey('clientes.id')) #conferir relacionamento def __repr__(self): return '<Site %r>' % self.descricao class Usuario(app.db.Model): __tablename__ = 'usuarios'
def run(self): newApp = app() newApp.login(self.name)
def app(): app = app() return app
def test(): test = app() yield test
def sendKey(self,key): app('System Events').keystroke(key, using=k.command_down) pass
from aux import fsdecode from app import * if __name__ == '__main__': if sys.hexversion < 0x02070000: print('Please run the script with python>=2.7') else: args = [fsdecode(x) for x in sys.argv] name = os.path.basename(args.pop(0)) if 'mplayer' in name: app = Player if len(args) > 0: if 'fetch' == args[0]: args.pop(0) app = Fetcher elif 'identify' == args[0]: args.pop(0) app = Identifier elif 'play' == args[0]: args.pop(0) elif 'mfetch' in name: app = Fetcher elif 'midentify' in name: app = Identifier else: app = Application app(args).run()
#print Param + str(number) + " " + "in vmstat" return number def get_list_info(self, infolist): local_device = device() valuelist = [] for i in range(len(infolist)): info = local_device.get_device_info(str(infolist[i])) valuelist.append(str(infolist[i]) + " " + str(info) + " ") return str("".join(valuelist)) if __name__ == '__main__': local_device = device() local_app = app() local_view = view() orig = "without" new = "withpatch" app_list = open("./littleapp.txt").readlines() orig_log = open(orig, "a+") new_log = open(new, "a+") infolist = ["nr_free_pages","nr_inactive_anon","nr_active_anon","nr_inactive_file", "nr_active_file", "nr_unevictable", "nr_mlock", "nr_anon_pages", "nr_mapped", "nr_file_pages", "compact_migrate_scanned", "compact_isolated", "pgrefill_dma32", "pgrefill_normal", "pgsteral_kswapd_dma32", "pgsteal_kswapd_normal", "pgsteal_direct_dma32", "pgsteal_direct_normal", "pgscan_kswapd_dma32", "pgscan_kswapd_normal", "pgscan_direct_dma32", "pgscan_direct_normal", "slabs_scanned", "unevictable_pgs_munlocked", "MemFree", "MemAvailable", "slabs_scanned"] # infolist = ["slabs_scanned", "pgscan_direct_normal", "pgscan_kswapd_normal", "MemFree"] # infolist = ["slabs_scanned"]