Пример #1
0
class TestApp:
    def setup(self):
        self.app = App().start()

    def teardown(self):
        self.app.stop()

    def test_app1(self):
        logger.info('test_app1')
Пример #2
0
class TestApp:

    def setup(self):
        self.app = App().start(udid='127.0.0.1:62025',port=4725)

    def teardown(self):
        self.app.stop()

    def test_app3(self):
        logger.info('test_app3')

    def test_app4(self):
        logger.info('test_app4')
class TestAddTcontact():

    #初始化app,并且到主页的位置
    def setup(self):
        self.main=App().strat().main()

    #参数化添加数据,用yaml数据驱动的方法
    @pytest.mark.parametrize("name,address,gender,input_phone",yaml.safe_load(open(r"../data/contact_add.yml",encoding="UTF-8")))
    def test_add_contact(self,name,address,gender,input_phone):
        #进入到通讯录,点击增加联系人,点击手动添加联系人,输入名字,输入地址、输入性别、输入电话、点击保存、确认添加成功的toast,点击back返回到通讯录页面
        self.main.goto_addresslist().click_addmember().\
            click_manual_add().input_name(name).input_address(address).\
            input_gender(gender).input_phone(input_phone).\
            click_save().verify_toast().click_back()
Пример #4
0
def edit_music(id: int):
    db = App.getDb().db
    music = db.query(File).filter(File.id == id).one_or_none()
    if music:
        music.meta.title = request.form['title']
        music.meta.artist = request.form['artist']
        music.meta.album = request.form['album']
        music.meta.date = request.form['date']
        music.meta.genre = request.form['genre']

        db.commit()

        audio = EasyID3(music.real_path)
        audio["title"] = request.form['title']
        audio["artist"] = request.form['artist']
        audio["album"] = request.form['album']
        audio["date"] = request.form['date']
        audio["genre"] = request.form['genre']

        audio.save()

        flash('Sikeresen átírtad a metaadatokat!', 'success')

        return redirect(url_for('edit_music_view', id=id))
    else:
        flash('Nem található ilyen file!', 'danger')
        return redirect(url_for('show_all_musics'))
Пример #5
0
def saveMusicFileToDb(path):
    db = App.getDb().db
    file = db.query(File).where(
        File.path == re.escape(os.path.abspath(path))).one_or_none()
    if file is None:
        meta = Meta()
        try:
            audio = EasyID3(path)
            for key in audio.keys():
                setattr(meta, key, audio[key])
                if (type(audio[key]) is list):
                    setattr(meta, key, ",".join(audio[key]))

        except:
            pass
        finally:
            file = File(path=re.escape(os.path.abspath(path)), meta=meta)
            db.add(file)
            try:
                db.commit()
            except ProgrammingError as e:
                logger.error(
                    str(type(e)) + " - " + str(e) + " - " + path + " - " +
                    str(e.statement) + " - " + str(e.params))
                db.rollback()
            except OperationalError as e:
                logger.error(
                    str(type(e)) + " - " + str(e) + " - " + path + " - " +
                    str(e.statement) + " - " + str(e.params))
                db.rollback()
            except SQLAlchemyError as e:
                logger.error(str(type(e)) + " - " + str(e) + " - " + path)
                db.rollback()
Пример #6
0
def edit_music_view(id: int):
    db = App.getDb().db
    music = db.query(File).filter(File.id == id).one_or_none()
    if music:
        return render_template("music-edit.html", music=music)
    else:
        flash('Nem található ilyen file!', 'danger')
        return redirect(url_for('show_all_musics'))
Пример #7
0
def on_moved(event):
    print(f"{event.src_path} has been moved to {event.dest_path}")
    db = App.getDb().db
    file = db.query(File).where(
        File.path == re.escape(os.path.abspath(event.src_path))).one_or_none()
    if file:
        file.path = re.escape(os.path.abspath(event.dest_path))
        db.commit()
Пример #8
0
def on_deleted(event):
    print(f"{event.src_path} has been deleted!")
    db = App.getDb().db
    file = db.query(File).where(
        File.path == re.escape(os.path.abspath(event.src_path))).one_or_none()
    if file:
        db.delete(file.meta)
        db.delete(file)
        db.commit()
Пример #9
0
def on_modified(event):
    print(f"{event.src_path} has been modified")
    db = App.getDb().db
    file = db.query(File).filter(
        File.path == re.escape(os.path.abspath(event.src_path))).one_or_none()
    if file:
        try:
            audio = EasyID3(event.src_path)
        except:
            print("No metadatas in this file")
        else:
            updateMeta(event.src_path, audio)
    else:
        on_created(event)
Пример #10
0
def updateMeta(path, audio):
    db = App.getDb().db
    file = db.query(File).filter(
        File.path == re.escape(os.path.abspath(path))).one_or_none()
    meta = file.meta
    if file:
        for key in audio.keys():
            setattr(meta, key, audio[key])
            if (type(audio[key]) is list):
                setattr(meta, key, ",".join(audio[key]))

    try:
        db.commit()
    except SQLAlchemyError as e:
        db.rollback()
        logger.error(str(type(e)) + " - " + str(e) + " - " + path)
Пример #11
0
def on_created(event):
    print(f"{event.src_path} has been created!")
    db = App.getDb().db
    file_check = db.query(File).where(
        File.path == re.escape(os.path.abspath(event.src_path))).one_or_none()
    if not file_check:
        file = File(path=re.escape(os.path.abspath(event.src_path)),
                    meta=Meta())
        db.add(file)
        db.commit()

    try:
        audio = EasyID3(event.src_path)
    except:
        print("No metadatas in this file")
    else:
        updateMeta(event.src_path, audio)
Пример #12
0
class Hupu_page():
    sousuokuang = (By.ID, "com.hupu.games:id/tv_banner2")
    shurukaung = (By.ID, "com.hupu.games:id/search_input")
    sousuoanniu = (By.ID, "com.hupu.games:id/search_btn_cancel")

    def __init__(self):
        self.a = Asser()
        self.app = App("hupu")

    def appsousuo(self):
        time.sleep(8)
        self.app.clic(*self.sousuokuang)
        time.sleep(3)
        self.app.send_key("NBA", self.shurukaung)
        # time.sleep(3)
        self.app.clic(*self.sousuoanniu)
        time.sleep(3)
        self.a.assert_activity(self.app.driver, "testantivity")
        self.app.quit()
Пример #13
0
 def setup(self):
     self.app = App().start(udid='127.0.0.1:62025',port=4725)
 def setup(self):
     self.main=App().strat().main()
Пример #15
0
def get_all_musics():
    db = App.getDb().db
    musics = db.query(File).all()
    musics_schema = FileSchema(many=True)
    return {"musics": musics_schema.dump(musics)}
Пример #16
0
 def setup(self):
     self.app = App().start()
Пример #17
0
import argparse
import os
import re

import markdown
from markdown.extensions.fenced_code import FencedCodeExtension
from markdown.extensions.tables import TableExtension

from common.app import App
from utils.smtp import SMTP

app_name = "markdown-mail"
CONFIG = App(app_name).config


def get_title(title, markdown_txt):
    """ 获取标题
    如果没有指定标题,则默认使用 Markdown 第一行文本作为标题
    如果第一行并非 H1 ,则返回 '无标题'
    """
    if title is not None:
        return title
    title_line = markdown_txt.split("\n")[0]
    if title_line.startswith("# "):
        return title_line[2:].rstrip()
    else:
        return "无标题"


def to_html(markdown_txt):
    """ 将 Markdown 文本转换为 HTML
 def setup(self):
     self.driver = App.open_app(html=False)
Пример #19
0
	def main():
		tornado.options.parse_command_line()
		http_server = tornado.httpserver.HTTPServer(App(config.Config.routes, **config.Config.settings))
		http_server.listen(options.port)
		tornado.ioloop.IOLoop.instance().start()
Пример #20
0
import subprocess
import threading
import time

import cv2
import itchat
try:
    from PIL import ImageGrab
except ImportError:
    import pyscreenshot as ImageGrab

from utils.compress import zip
from common.app import App

app_name = 'wechat_viewer'
APP = App(app_name)

Help_Msg = """Wechat Viewer is running ...
- help
- prtsc
- prtph
- fget <file_path>
- > <cmd_string>
"""


@itchat.msg_register('Text')
def text_reply(msg):
    message = msg['Text']
    user_name = msg['FromUserName']
    to_user_name = msg['ToUserName']
Пример #21
0
import argparse

from common.app import App
from utils.ssh import Server, LoginError


app_name = "sshell"
CONFIG = App(app_name).config

def login(host, port, username, password):
    try:
        server = Server(
            host,
            port,
            username,
            password
            )
        return server
    except LoginError as le:
        print(le.message)
        return None

def loop(server):
    try:
        i = input('{}@{}:{}$ '.format(server.username,
                                    server.exec('hostname')[0].strip('\n'),
                                    server.exec('pwd')[0].strip('\n')))
        stdout, stderr = server.exec(i)
        if stdout:
            print(stdout)
        if stderr:
Пример #22
0
 def __init__(self):
     self.a = Asser()
     self.app = App("hupu")