Esempio n. 1
0
# -*- coding: utf-8 -*-
from utils.snippet import on_method_ready
from Constant import YosemiteApk, YosemitePackage
from utils.apkparser import APK
from utils.Logger import getLogger

LOGGING = getLogger("CocAssistant.Yosemite")

class Yosemite(object):
    """Wrapper class of Yosemite.apk, used by javacap/recorder/yosemite_ime."""

    def __init__(self, adb):
        self.adb = adb

    def install_or_upgrade(self):
        """
        Install or update the Yosemite.apk file on the device

        Returns:
            None

        """
        self._install_apk_upgrade(YosemiteApk, YosemitePackage)

    def _install_apk_upgrade(self, apk_path, package):
        """
        Install or update the `.apk` file on the device

        Args:
            apk_path: full path `.apk` file
            package: package name
Esempio n. 2
0
# -*- coding: utf-8 -*-
import struct
from android.Yosemite import Yosemite
import android.adb
from utils.snippet import on_method_ready, reg_cleanup
from utils.nbsp import NonBlockingStreamReader
from utils.safesocket import SafeSocket
from utils.Logger import getLogger

LOGGING = getLogger("CocAssistant.javaCap")


class Javacap(Yosemite):
    """
    This is another screencap class, it is slower in performance than minicap, but it provides the better compatibility
    """

    APP_PKG = "com.netease.nie.yosemite"
    SCREENCAP_SERVICE = "com.netease.nie.yosemite.Capture"
    RECVTIMEOUT = None

    def __init__(self, adb):
        super(Javacap, self).__init__(adb)
        self.frame_gen = None

    @on_method_ready('install_or_upgrade')
    def _setup_stream_server(self):
        """
        Setup stream server

        Returns:
Esempio n. 3
0
# -*- coding: utf-8 -*-
from android.adb import ADB
from android.javacap import Javacap
import threading
from utils import utils, aircv
from utils.Logger import getLogger
from error import DeviceConnectionError
from .QtUtils import SendLoggingToQt
from threading import Timer

LOGGING = getLogger("CocAssistant.ScreenFrame")

class ScreenFrame (object) :
    def __init__(self, sendLoggingToQt) :
        instAdb = ADB("127.0.0.1:62001")
        self.instJavacap = Javacap(instAdb)
        self.sendLoggingToQt = sendLoggingToQt

    def start(self) :
        self._thread = Timer(0.01, self._monitor)
        self._thread.start()

    def stop(self) :
        self._thread.cancel()
        self._thread = None

    def _monitor(self):
        screen = self.getFrame()
        screen = utils.string_2_img(screen)
        # aircv.imwrite(".\\temp\\screen.jpg", screen, 10)
        if not self.sendLoggingToQt.stop :
Esempio n. 4
0
# -*- coding: utf-8 -*-

from utils.Logger import getLogger, initLogging
from GUI.MainWindows import MyWidget
from PySide6.QtWidgets import QApplication
from BLL.LoggingToGui import LoggingToGui
from Constant import AppWindowsName
import queue
from BLL.Execute import Execute
from BLL.ScreenFrame import ScreenFrame
from BLL.QtUtils import SendLoggingToQt
import numpy as np

LOGGING = getLogger("CocAssistant.Main")

if __name__ == "__main__" :
    myQueue = queue.Queue(100)
    initLogging(myQueue)
    m_sendLoggingToQt = SendLoggingToQt()
    m_LoggingToGui = LoggingToGui(myQueue, m_sendLoggingToQt)
    m_LoggingToGui.start()
    m_execute = Execute(m_sendLoggingToQt)

    m_sendLoggingToQt2 = SendLoggingToQt()
    screenFrame = ScreenFrame(m_sendLoggingToQt2)

    app = QApplication([])
    widget = MyWidget()

    m_sendLoggingToQt2.sendLogging[np.ndarray].connect(widget.refreshScreen)
    widget.signalStop.connect(m_sendLoggingToQt2.close)
Esempio n. 5
0
import sqlite3
from utils.Logger import getLogger

LOGGING = getLogger("CocAssistant.myOrc")

class Character(object) :
    m_hash = None
    m_point = None
    m_value = None
    def __init__ (self) :
        self._connet = sqlite3.connect('E:\\cocAssistant\\core\\db\\myOrc.db')
        self._cursor = self._connet.cursor()

    def setChar(self, m_point, m_hash, m_value = None) :
        if not self.hasChar(m_hash) :
            if m_value :
                m_state = True
            else :
                m_state = False
            self._cursor.execute("insert into Font (state, value, point, hash) values (?, ?, ?, ?)", (m_state, m_value, m_point, m_hash))
            self._connet.commit()
            LOGGING.debug(f"insert state = {m_state}, value = {m_value}, point = {m_point}, hash = {m_hash} into Font")
            return True
        else :
            LOGGING.debug(f"can not insert value = {m_value}, point = {m_point}, hash = {m_hash} into Font")
            return False

    def hasChar(self, m_hash) :
            self._cursor.execute("select state from Font where hash == ?", (m_hash,))
            if self._cursor.fetchone() :
                # LOGGING.debug("has charact in Font")
Esempio n. 6
0
# # -*- coding: utf-8 -*-
import sys
import random
from Constant import AppWindowsName
from PySide6 import QtCore, QtWidgets, QtGui
from PySide6.QtWidgets import *
from PySide6.QtCore import QBasicTimer
from utils.Logger import getLogger
from utils import utils
import numpy as np

LOGGING = getLogger("CocAssistant.MainWindows")


class MyWidget(QtWidgets.QWidget):
    sendSendExecute = QtCore.Signal(str)
    signalStop = QtCore.Signal()

    def __init__(self):
        super(MyWidget, self).__init__()
        self.setWindowTitle(AppWindowsName)
        self.layout = QtWidgets.QVBoxLayout()
        self.labelRemote = QLabel(self)
        self.layout.addWidget(self.labelRemote)

        self.textShow = QTextBrowser(self)
        self.layout.addWidget(self.textShow)

        self.textInput = QLineEdit(self)
        self.textInput.returnPressed.connect(self.inputText)
        self.layout.addWidget(self.textInput)