Exemple #1
0
    def takePicture(this, facialRecognition):
        sqlCursor = this._getCursor()
        timeStamp = time()
        path = "data/pictures/{}.jpg".format(str(timeStamp))
        try:
            camera = PiCamera()
            #camera.resolution = (1366, 768)
            camera.capture(path)
            camera.close()
        except:
            call("wget http://localhost:8080/?action=snapshot -O {}".format(
                path))

        q = "convert {} -pointsize 20  \
        -fill black -draw 'rectangle 5,12,200,45' \
        -fill white -annotate +10+35 '{}' \
        {}".format(path, strftime('%Y-%m-%d %H:%M:%S', localtime(timeStamp)),
                   path)

        print(q)
        call(q)

        if facialRecognition:
            personID = this.compare(path)
            mainQuery = "INSERT INTO main VALUES (NULL,0,{},'{}',{})"\
            .format(int(timeStamp),path,personID)
        else:
            mainQuery = "INSERT INTO main VALUES (NULL,0,{},'{}',-2)".format(
                int(timeStamp), path)
        #endif

        sqlCursor.execute(mainQuery)
        this.sqlConn.commit()

        if this.notify:
            try:
                if facialRecognition:
                    this.sendNotification(this._getNameOfPerson(personID),
                                          '/' + path)
                    return personID
                else:
                    this.sendNotification(this._getNameOfPerson(-2),
                                          '/' + path)
                pass
                #endif
            except KeyError:
                this.sendFile(path)

        return personID
Exemple #2
0
def parse(argv):
    cmd = argv[1]
    if not commands.exists(cmd):
        print("command does not exist")
        return 1
    flags = []
    opts = []
    for e in argv[2:]:
        if e.startswith("-"):
            flags.append(e)
        else:
            opts.append(e)

    commands.call(cmd, flags, opts)

    return 0
 def adb(self):
     '''
     get the executable path of adb
     '''
     if self.__adb_cmd is None:
         filename = "adb.exe" if os.name == 'nt' else "adb"
         adb_cmd = call('which %s' % filename)
         if not os.path.exists(adb_cmd):
             raise EnvironmentError('adb not found from $PATH')
         self.__adb_cmd = adb_cmd
     return self.__adb_cmd
Exemple #4
0
 def adb(self):
     '''
     get the executable path of adb
     '''
     if self.__adb_cmd is None:
         filename = "adb.exe" if os.name == 'nt' else "adb"
         adb_cmd = call('which %s' % filename)
         if not os.path.exists(adb_cmd):
             raise EnvironmentError('adb not found from $PATH')
         self.__adb_cmd = adb_cmd
     return self.__adb_cmd
Exemple #5
0
    def _reBuildgal(this):
        mainGal = './data/enroll/main.gal'
        backupGal = './data/enroll/main.bak'
        rename(mainGal, backupGal)
        sqlCursor = this._getCursor()
        ids = this._getIdOfAllUsers()

        arr = []
        for userID in ids:
            query = "SELECT id from enroll where personID = {} order by id DESC".format(
                userID[0])
            sqlCursor.execute(query)
            pictureIDs = sqlCursor.fetchall()
            for pictureID in pictureIDs:
                fileName = './data/enroll/{}.jpg'.format(pictureID[0])
                arr.append(fileName)

        final = ''
        for i in arr:
            final += " {}".format(i)

        call("br -algorithm FaceRecognition -enroll {} ./data/enroll/main.gal".
             format(final))
Exemple #6
0
def instrument(method_name, class_name, componment_name):
    cmd = local_cmd % (class_name, method_name, componment_name)
    ret = call(cmd)
    vmap = {}
    result_tag = 'INSTRUMENTATION_RESULT: '
    code_tag = 'INSTRUMENTATION_CODE'
    code_match = re.search(code_tag, ret)
    code_index = code_match.start()
    result_match = re.search(result_tag, ret)
    results = ret[result_match.end():code_index].strip().replace('\r\n', ' ')
    index = results.index('=')
    key = results[0:index]
    value = results[(index + 1):]
    vmap[key] = value
    return vmap
Exemple #7
0
def instrument(params):
    cmd = local_cmd % (params['class'], params['method'], params['componment'])
    ret = call(cmd)
    vmap = {}
    result_tag = 'INSTRUMENTATION_RESULT: '  
    code_tag = 'INSTRUMENTATION_CODE'
    code_match = re.search(code_tag, ret)
    code_index = code_match.start()
    result_match = re.search(result_tag, ret)
    results = ret[result_match.end(): code_index].strip().replace('\r\n', ' ')
    index = results.index('=')
    key = results[0: index]
    value = results[(index+1):]
    vmap[key] = value
    return vmap
Exemple #8
0
def instrument(method_name, class_name, componment_name):
    cmd = local_cmd % (class_name, method_name, componment_name)
    ret = call(cmd)
    vmap = {}
    result_tag = "INSTRUMENTATION_RESULT: "
    code_tag = "INSTRUMENTATION_CODE"
    code_match = re.search(code_tag, ret)
    code_index = code_match.start()
    result_match = re.search(result_tag, ret)
    results = ret[result_match.end() : code_index].strip().replace("\r\n", " ")
    index = results.index("=")
    key = results[0:index]
    value = results[(index + 1) :]
    vmap[key] = value
    return vmap
Exemple #9
0
 def _trainAndCopy(this, picture, id):
     fileName = './data/enroll/{}.jpg'.format(id)
     copyfile(picture, fileName)
     call("br -algorithm FaceRecognition -enroll {} ./data/enroll/temp.gal".
          format(fileName))
     copyfile("./data/enroll/main.gal", "./data/enroll/temp1.gal")
     call(
         "br -cat ./data/enroll/temp.gal ./data/enroll/temp1.gal ./data/enroll/main.gal"
     )
     call("rm ./data/enroll/temp1.gal ./data/enroll/temp.gal")
def install_linux_app(application_name):
    logging.info("Installing {application_name} ...".format(
        application_name=application_name))

    cmd.call("ls")
    cmd.call("ls -1t")
    cmd.call("ls -A -l")

    cmd.run("ls", ["-l", "-A", "-t"])
    cmd.run("ps -Al | head ")
    cmd.run("ls -Al | grep command")
Exemple #11
0
def instrument(test):
    local_cmd = 'adb shell am instrument -w -r -e class %s#%s %s'
    #get the JAVA test class and method name by module path and name
    params = {'class': '%s.%s' % (test.__module__, type(test).__name__),
              'method': test._testMethodName,
              'componment':  test.inst_componment
              }

    cmd = local_cmd % (params['class'], params['method'], params['componment'])
    ret = call(cmd)
    vmap = {}
    result_tag = 'INSTRUMENTATION_RESULT: '  
    code_tag = 'INSTRUMENTATION_CODE'
    code_match = re.search(code_tag, ret)
    code_index = code_match.start()
    result_match = re.search(result_tag, ret)
    results = ret[result_match.end(): code_index].strip().replace('\r\n', ' ')
    index = results.index('=')
    key = results[0: index]
    value = results[(index+1):]
    vmap[key] = value
    return vmap
Exemple #12
0
def instrument(test):
    local_cmd = 'adb shell am instrument -w -r -e class %s#%s %s'
    #get the JAVA test class and method name by module path and name
    params = {
        'class': '%s.%s' % (test.__module__, type(test).__name__),
        'method': test._testMethodName,
        'componment': test.inst_componment
    }

    cmd = local_cmd % (params['class'], params['method'], params['componment'])
    ret = call(cmd)
    vmap = {}
    result_tag = 'INSTRUMENTATION_RESULT: '
    code_tag = 'INSTRUMENTATION_CODE'
    code_match = re.search(code_tag, ret)
    code_index = code_match.start()
    result_match = re.search(result_tag, ret)
    results = ret[result_match.end():code_index].strip().replace('\r\n', ' ')
    index = results.index('=')
    key = results[0:index]
    value = results[(index + 1):]
    vmap[key] = value
    return vmap
Exemple #13
0
               'method': 'testAsAttributeSet',
               'componment': 'com.android.cts.util/android.test.InstrumentationCtsTestRunner'


#local_cmd_tmp = 'adb shell am instrument -e class <class_name>#<method> -w <TEST_PACKAGE_NAME>/<RUNNER_CLASS_NAME>

local_cmd = 'adb shell am instrument -w -r -e class %s#%s %s'

def instrument(params):
        """
        Samary:instrument
        Step1:
        Step2:
        """
    cmd = local_cmd % (params['class'], params['method'], params['componment'])
    ret = call(cmd)
    if ret.find('OK') == -1:
        assert 1, 'ok'
    else:
        assert 0, 'inst failed'


def testGen():
        """
        Samary:test gen
        """
    yield instrument, inst_params

inst_params2 = {'class': 'android.util.cts.XmlTest',
               'method': 'testAsAttributeSet',
               'package': 'com.android.cts.util',
Exemple #14
0
def main():
    modules = []
    call(__prog_name__, __version__, modules)
Exemple #15
0
def main(argc, argv):
    if argc < 2:
        commands.call("")
    else:
        parse(argv)
Exemple #16
0
def main():
    if conf:
        modules = getattr(conf, 'plugins', [])
    else:
        modules = []
    call('parm', __version__, modules)
Exemple #17
0
def main():
    modules = []
    call(__prog_name__, __version__, modules)