示例#1
0
def main(request):
    if request.method == "POST":
        value = 0
        if request.path == "/users/login" or request.path == "/users/login/":
            value = UsersModel().login(user=request.POST['user'],password=request.POST['password'])
        elif request.path == "/users/add" or request.path == "/users/add/":
            value = UsersModel().add(user=request.POST['user'],password=request.POST['password'])
        if value > 0:
            return HttpResponse(json.dumps({"errCode":1,"count":value}),content_type='application/json', status=200)
        elif value < 0:
            return HttpResponse(json.dumps({"errCode":value}),content_type='application/json', status=200)
        if request.path =="/TESTAPI/resetFixture" or request.path =="/TESTAPI/resetFixture/":
            return HttpResponse(json.dumps({"errCode":UsersModel().TESTAPI_resetFixture()}),content_type='application/json', status=200)
        elif request.path == "/TESTAPI/unitTests" or request.path == "/TESTAPI/unitTests/":
            results = Popen("python manage.py test Login".split(),stderr=PIPE,shell=False).communicate()[1]
            char = results.rfind("Ran")+4
            numTests = results[char:char+2]
            echar = results.rfind("failures=")+7
            if echar < 7:
                numFailed = 0
            else :
                numFailed = results[echar:echar+1]
            output = ""
            return HttpResponse(json.dumps({"nrFailed":numFailed,"output":results,"totalTests":numTests}),content_type='application/json', status=200)
    else:
        return render_to_response('Login/client.html',{})
示例#2
0
def getOrientationFromExif(source):
    orientations = [
        None, None, 'Mirror horizontal', 'Rotate 180', 'Mirror vertical',
        'Mirror horizontal and Rotate 270 CW', 'Rotate 90 CW',
        'Mirror horizontal and rotate 90 CW', 'Rotate 270 CW'
    ]

    exifcommand = os.getenv('MASKGEN_EXIFTOOL', 'exiftool')
    rotateStr = Popen([exifcommand, '-n', '-Orientation', source],
                      stdout=PIPE).communicate()[0]

    rotation = rotateStr.split(
        ':')[1].strip() if rotateStr.rfind(':') > 0 else '-'

    if rotation == '-':
        return None
    try:
        rotation_index = int(rotation)
        return orientations[rotation_index]
    except:
        return None
#使用android-sdk下面的aapt: launchable-activity: name='tv.danmaku.bili.ui.splash.SplashActivity'  label='' icon=''
#使用tools下面的aapt: launchable activity name='tv.danmaku.bili.ui.splash.SplashActivity'label='' icon=''
        cmd = AAPT_PATH + ' dump badging "%s" | grep "launchable-activity"'
        launchableActivityRegex = re.compile(
            r"launchable-activity: name='(.*)'  label='(.*)' icon='(.*)'",
            re.I)
        try:
            lauchableActivity = Popen(cmd % self.apkPath,
                                      stdout=PIPE,
                                      shell=True).communicate()[0].replace(
                                          '\n', '')
            splitLaunchable = lauchableActivity.split('launchable-activity')
            if len(splitLaunchable) > 2:
                lauchableActivity = lauchableActivity[
                    0:lauchableActivity.rfind('launchable-activity')]
            m = launchableActivityRegex.search(lauchableActivity)
            if m:
                self.apkInfo['launchableActivity'] = m.group(1)
            else:
                self.apkInfo['launchableActivity'] = 'noActivity'
        except Exception, e:
            print 'get lauchable activity catch exception, cmd is %s, error is %s' % (
                cmd, e)

        size = ceil(os.path.getsize(self.apkPath) / (1024 * 1000.0))
        self.apkInfo['apkSize'] = str(size) + "M"


def getApkInfo(apkFile):
    apkInfoObj = ApkInfo(apkFile)
示例#4
0
crab.checkCredentials(0)

# check setup

toCheck = ["scram", "crab"]

for i in toCheck:
    log.output("--> Checking if you have " + i + " in your path")
    check = Popen("which " + i,
                  shell=True,
                  stdin=PIPE,
                  stdout=PIPE,
                  stderr=STDOUT,
                  close_fds=True).stdout.read()

    if not check.rfind("no " + i + " in") == -1:
        log.output(" ---> ERROR:  you don't have " + i +
                   " in your path, did you read the twiki instructions?")

        if options.stdout:
            print "Fatal ERROR, script exiting"
        else:
            print "Fatal ERROR, script exiting. Please consult " + logFileName + " for more information"
        sys.exit(1)

if options.attach == None:

    # now prepare our crab cfg

    #print crabCfgName
crab.crabSource = "source /etc/profile.d/set_globus_tcp_port_range.sh; export EDG_WL_LOCATION=/opt/edg "

# check GRID proxy

crab.checkGridProxy(0)
crab.checkCredentials(0)

# check setup

toCheck = ["scram","crab"]

for i in toCheck:
    log.output("--> Checking if you have "+i+" in your path")
    check = Popen("which "+i, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True).stdout.read()

    if not check.rfind("no "+i+" in") == -1:
        log.output(" ---> ERROR:  you don't have "+i+" in your path, did you read the twiki instructions?")

        if options.stdout:
            print "Fatal ERROR, script exiting"
        else:
            print "Fatal ERROR, script exiting. Please consult "+logFileName+" for more information"
        sys.exit(1)

if options.attach == None:
        
    # now prepare our crab cfg

    #print crabCfgName
    
    crab.parseCRABcfg(timestamp,options.dir,crabCfgName)