Esempio n. 1
0
def GetPointData(info):
    reconstruction = Info.ReadReconstructionData(info)['shots']
    reconstruction_data = []
    latlon_data = []
    frame_lst = []
    f = open(Info.GetMatchLstFileName(info), 'r')
    for line in f:
        line = line[0:-1].split('\t')
        frame_name = line[0]
        pano_name = line[1]
        try:
            [x, y, z] = optical_center(reconstruction[frame_name])
        except:
            continue
        lat = float(line[2])
        lon = float(line[3])
        frame_lst.append(line[0])
        reconstruction_data.append([x, y])
        latlon_data.append([lat, lon])
    f.close()
    reconstruction_data = np.array(reconstruction_data, dtype=np.float32)
    latlon_data = np.array(latlon_data, dtype=np.float32)

    #plt.figure()
    #plt.subplot('111')
    #plt.plot(reconstruction_data[:,0], reconstruction_data[:,1], 'o')
    #plt.show()

    return [frame_lst, reconstruction_data, latlon_data]
Esempio n. 2
0
def import_template():
    if os.path.isfile("./Resources/template.json"):
        with open('./Resources/template.json') as data_file:
            temp = json.load(data_file)
    else:
        temp = {}
        id = visuals.get_text_input("Template ID",
                                    "Please paste the ID of a sample file")
        if not id:
            exit()
        sheets = Info.get_sheets(id)
        temp['sheets'] = []
        for title in sheets:
            row_num = visuals.get_number_input(
                "Header Row",
                "What is the header row for sheet '{0}'".format(title))
            row = Info.get_row(id, title, row_num)
            rows = []
            if row_num > 1:
                rows = Info.get_first_col(id, title, row_num)
            temp['sheets'].append({
                'title': title,
                'header_row': row_num,
                'header_columns': row,
                'rows': rows
            })
    Template.set_template(temp)
Esempio n. 3
0
def moveSheet(title, index, spreadsheet=None):
    id = Info.getSheetId(spreadsheet, title=title)
    if id < 0:
        return

    if Info.getSheetIndex(spreadsheet, title) <= (int(index) - 1):
        index = int(index)
    else:
        index = int(index) - 1
    request = SHEET_SERVICE.spreadsheets().batchUpdate(
        spreadsheetId=spreadsheet['id'],
        body={
            "requests": [{
                "updateSheetProperties": {
                    "properties": {
                        "sheetId": id,
                        "index": index
                    },
                    "fields": "index"
                }
            }]
        })

    try:
        request.execute()
        RateLimiter.write_request()
    except HttpError as err:
        Log.err(spreadsheet, err, True)
Esempio n. 4
0
def move_column(sheet_title, column, location, spreadsheet=None):
    location = int(location)
    index = Info.getColumnIndex(spreadsheet, sheet_title, column)

    if index < 0:
        return

    if location > index:
        location += 1

    #print(location)
    #print(index)
    request = SHEET_SERVICE.spreadsheets().batchUpdate(
        spreadsheetId=spreadsheet['id'],
        body={
            "requests": [{
                "moveDimension": {
                    "source": {
                        "sheetId": Info.getSheetId(spreadsheet, sheet_title),
                        "dimension": "COLUMNS",
                        "startIndex": index,
                        "endIndex": index + 1
                    },
                    "destinationIndex": location
                }
            }]
        })

    try:
        request.execute()
        RateLimiter.write_request()
    except HttpError as err:
        Log.err(spreadsheet, err, True)
Esempio n. 5
0
def delete_column(sheet_title, column, spreadsheet=None):
    index = Info.getColumnIndex(spreadsheet, sheet_title, column)
    if index < 0:
        return
    request = SHEET_SERVICE.spreadsheets().batchUpdate(
        spreadsheetId=spreadsheet['id'],
        body={
            "requests": [
                {
                    "deleteDimension": {
                        "range": {
                            "sheetId": Info.getSheetId(spreadsheet,
                                                       sheet_title),
                            "dimension": "COLUMNS",
                            "startIndex": index,
                            "endIndex": index + 1
                        }
                    }
                },
            ]
        })
    try:
        request.execute()
        RateLimiter.write_request()
    except HttpError as err:
        Log.err(spreadsheet, err, True)
def RunRANSAC(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    subprocess.call('rm %s' % (Info.GetGCPFileName(info)), shell=True)
    [frame_lst, reconstruct_set, latlon_set] = GetPointData(info)
    if len(reconstruct_set) == 0 or len(latlon_set) == 0:
        return
    #try:
    [M, model] = RANSAC_2D(reconstruct_set,
                           latlon_set,
                           iteration=1000,
                           tolerance=Info.Config.STEP_TEN_METER)
    print M
    #except:
    #    return
    if not M is None and not model is None:
        reconstruct = Info.ReadReconstructionData(info)['shots']
        f = open(Info.GetGCPFileName(info), 'w')
        frame_lst = sorted(reconstruct.keys())
        for index, frame in enumerate(frame_lst):
            [x, y, z] = optical_center(reconstruct[frame])
            point = np.dot(M,
                           np.transpose(np.array([x, y, 1], dtype=np.float32)))
            s = '%s\t%f\t%f\n' % (frame, point[0], point[1])
            f.write(s)
        f.close()
Esempio n. 7
0
def delete_sheet():
    title = visuals.get_app().getTabbedFrameSelectedTab("SheetFrame")
    if visuals.get_app().yesNoBox(
            "Confirm Delete",
            "Are you sure you delete sheet '{0}'?".format(title)):
        Bulk.deleteSheet(title)
        Template.delete_sheet(title)
        Info.deleteSheet(title)
        visuals.edit_files()
Esempio n. 8
0
def rename_sheet():
    title = visuals.get_app().getTabbedFrameSelectedTab("SheetFrame")
    new_title = visuals.get_app().textBox(
        "Rename " + title,
        "Please enter a new name for sheet '{0}':".format(title))
    if new_title:
        Bulk.renameSheet(title, new_title)
        Template.rename_sheet(title, new_title)
        Info.rename_sheet(title, new_title)
        visuals.edit_files()
Esempio n. 9
0
def delete_col():
    sheet = visuals.get_app().getLabel("title").split("'")[1]
    col = visuals.get_app().getOptionBox("cols")
    if visuals.get_app().yesNoBox(
            "Confirm Delete",
            "Are you sure you delete column '{0}' from sheet '{1}'?".format(
                col, sheet)):
        Bulk.delete_column(sheet, col)
        Template.delete_column(sheet, col)
        Info.delete_columns(sheet)
        visuals.get_app().changeOptionBox("cols", Template.get_columns(sheet),
                                          0)
Esempio n. 10
0
def rename_col():
    sheet = visuals.get_app().getLabel("title").split("'")[1]
    col = visuals.get_app().getOptionBox("cols")
    new_col = visuals.get_app().textBox(
        "Rename Column",
        "Please enter a new name for column '{0}' in sheet '{1}':".format(
            col, sheet))
    if new_col:
        Bulk.rename_column(sheet, col, new_col)
        Template.rename_column(sheet, col, new_col)
        Info.rename_column(sheet, col, new_col)
        visuals.get_app().changeOptionBox("cols", Template.get_columns(sheet),
                                          0)
Esempio n. 11
0
def move_col():
    sheet = visuals.get_app().getLabel("title").split("'")[1]
    col = visuals.get_app().getOptionBox("cols")
    loc = visuals.get_app().textBox(
        "Move Column",
        "Please enter the location (A, B, etc) to which you would like to move column "
        "'{0}' in sheet '{1}':".format(col, sheet))
    if loc:
        index = Info.col_to_index(loc)
        Bulk.move_column(sheet, col, index)
        Template.move_column(sheet, col, index)
        Info.delete_columns(sheet)
        visuals.get_app().changeOptionBox("cols", Template.get_columns(sheet),
                                          0)
Esempio n. 12
0
def move_sheet():
    title = visuals.get_app().getTabbedFrameSelectedTab("SheetFrame")
    max = len(Template.get_sheets())
    index = visuals.get_app().numberBox(
        "New Index",
        "Please pick a new index, min of 1, max of {0}:".format(max))
    if index and 0 < index <= max:
        Bulk.moveSheet(title, index)
        Template.moveSheet(title, index)
        Info.invalidate_indexes()
        visuals.edit_files()
    elif index and (index < 0 or index > max):
        visuals.get_app().errorBox(
            "Number Error",
            "The index you entered was outside the acceptable range")
Esempio n. 13
0
 def __init__(self):
     self.aPlot = AmmoniaPlot.AmmoniaPlot()
     self.energy = Energy.Energy()
     self.info = inf.Info()
     self.total = False
     self.sp = False
     self.rAndM = False
     self.omegas = False
     self.sensibility = False
     self.tofSensibility = False
     self.kindOfSensibility = False
     self.lmbdas = False
     self.one = False
     self.ext = ""
     self.labelAlfa = [
         r"P1  $V \rightarrow NH_3$",  # P1
         r"P2  $NH_3 \rightarrow V$",  # P2
         r"P3  $2V + O_2(g) \rightarrow 2O$",  # P3
         r"P4  $2O \rightarrow 2V + O_2(g)$",  # P4
         r"P5  $NH_3 + O \rightarrow NH_2 + OH$",  # P5
         r"P6  $NH_2 + OH \rightarrow NH + H_2O(g)$",  # P6
         r"P7  $NH + OH \rightarrow N + H_2O(g)$",  # P7
         r"P8  $NH + O \rightarrow N + OH$",  # P8
         r"P9  $N + O \rightarrow NO + V$",  # P9   TOF
         r"P10$N + N \rightarrow N_2(g)$",  # P10  TOF
         r"P11$NO \rightarrow V$",  # P11
         r"P12$N \rightarrow N$",  # P12
         r"P13$O \rightarrow O$",  # P13
         r"P14$OH \rightarrow OH$",  # P14
         r"P15$NH_2 + O \rightarrow NH + OH$",  # P15
         r"P16$NH + OH \rightarrow NH_2 + O$",  # P16
         r"P17$NH_2 + OH \rightarrow NH_3 + O$",  # P17
         r"P18$N + OH \rightarrow NH + O$"
     ]  # P18
Esempio n. 14
0
def MatchFunM(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    frame_sift_lst = [x for x in sorted(os.listdir(info['frame_sift_path'])) if x.endswith('.sift')]
    pano_sift_lst = [x for x in sorted(os.listdir(info['pano_sift_path'])) if x.endswith('.sift')]

    results = np.load('%s/fisher_results.npy'%info['pano_path'])
    MM = []
    for index, name in enumerate(frame_sift_lst):
        Mi = []
        frame_short_name = name.split('.')[0]
        for i in range(0,results.shape[1]):
            pano_name = pano_sift_lst[results[index, i]]
            pano_short_name = pano_name.split('.')[0]
            kp_pairs = lib_SIFTmatch.flann_match('%s/%s'%(info['frame_sift_path'],frame_short_name),
                                                 '%s/%s'%(info['pano_sift_path'],pano_short_name))
            #print kp_pairs
            try:
                (mkp1, mkp2) = zip(*kp_pairs)
                mkp1_pts = [ (x[0],x[1]) for x in mkp1 ]
                mkp2_pts = [ (x[0],x[1]) for x in mkp2 ]
                mkp1_pts = np.float32(mkp1_pts)
                mkp2_pts = np.float32(mkp2_pts)
                F, mask = cv2.findFundamentalMat(mkp1_pts,mkp2_pts,cv2.FM_RANSAC,20)
                q_pts = mkp1_pts[mask.ravel()==1]
                t_pts = mkp2_pts[mask.ravel()==1]
                Mi.append(len(q_pts))
            except:
                Mi.append(0)
                continue
        MM.append(Mi)
    np.save('%s/results_fundM'%info['pano_path'],MM)    
Esempio n. 15
0
 def highlight_info(self):
     if self.highlight_changed:
         token_name = self.health_tokens[self.highlighted_index].type.name
         self._highlight_info = '\n'.join(
             Info.complete_info(("Token", token_name), 10))
         self.highlight_changed = False
     return self._highlight_info
def DownloadPano(ID):
    info = Info.GetVideoInfo(ID)
    print ID
    circle = PanoProcess.GetCircleBound.GetCircleBound(info['location'])
    #print circle
    id_lst = []
    start_time = time.time()
    for loc in circle:
        #print loc
        try:
            panoid = PanoProcess.GetPanoID(loc)
        except:
            continue
        if panoid != None and not panoid in id_lst:
            id_lst.append(panoid)
            #a = time.time()
            PanoProcess.GetPanoByID.GetPanoByID(panoid, info['pano_download_path'])
            #print time.time() - a
    pano_lst = [x for x in sorted(os.listdir(info['pano_download_path'])) if x.endswith('.jpg')]
    f_name = '%s/pano_lst.txt'%info['pano_path']
    f = open(f_name, 'w')
    for img_name in pano_lst:
        s = img_name + '\n'
        f.write(s)
    f.close()
    end = time.time()
    print '%s use %f minutes and total %d images'%(ID, (end-start_time)/60, len(id_lst))
Esempio n. 17
0
def GetVideoTime(video_info):
    ID = video_info[0][0]
    CutFrame = video_info[0][1]
    Name = video_info[1]
    print ID, CutFrame
    info = Info.GetVideoInfo(ID)
    f_name = Info.Config.VIDEO_SOURCE_FOLDER + '/%d.mp4' % int(ID)
    video = mve.VideoFileClip(f_name)
    end_second = (CutFrame - 1) / video.fps
    start_second = end_second - 25
    frame_lst = [
        x for x in sorted(os.listdir(info['frame_path'])) if x.endswith('.jpg')
    ]
    if start_second >= 0:
        f = open('%s/timeline.json' % info['match_path'], 'w')
        t = start_second
        inter = 0.2  # 0.25 s
        d = {}
        d['time'] = {}
        for i in frame_lst:
            #print i
            d['time'][i] = t
            t += inter
        d['time'] = OrderedDict(sorted(d['time'].items()))
        d['id'] = Name
        f.write(json.dumps(d, indent=4) + '\n')
        f.close()
        return False
    else:
        return True
Esempio n. 18
0
  def computeMavgAndOmega(self, fileNumber):
      p = self.info
      name = "dataAePossibleFromList"#name = "dataAeAll"
      inf = Info.Info()
      inf.setParams()
      #pTemp = inf.getInformationFromFile()
      ratios = inf.getRatiosTotal()[p.minA:p.maxA]
      possiblesFromList = np.loadtxt(fname=name+"{:03d}".format(fileNumber)+".txt")
      time = np.array(possiblesFromList[:p.mMsr,0])
      possiblesFromList = possiblesFromList[:,1:] # remove time
 
      Mavg = np.zeros(shape=(p.mMsr,p.maxA-p.minA))
      for i,a in enumerate(range(p.minA,p.maxA)): # iterate alfa
          Mavg[:,i] = (possiblesFromList[:p.mMsr,a])/time/p.sizI/p.sizJ
          if a == 2:
              Mavg[:,i] = 2*Mavg[:,i]
      
      totalRate = np.array(ratios.dot(np.transpose(Mavg)))#/time/p.sizI/p.sizJ
      #totalRate = (totalRate+occupied)/time/p.sizI/p.sizJ
      # define omegas 
      omega = np.zeros(shape=(p.mMsr,p.maxA-p.minA)) # [co2amount, alfa]
      for i in range(0,p.mMsr):
          omega[i,:] =  Mavg[i,:] * ratios / totalRate[i]
          #omega[i,:] =  (Mavg[i,:]+occupied[i]) * ratios / totalRate[i]
      return Mavg, omega, totalRate, ratios
Esempio n. 19
0
def duplicateBlock():
    # Duplicate the info.
    print('---- TEST Duplicate -----')
    Block_ID = request.json['Block_ID']
    Address = request.json['Address']
    Stored = request.json['Stored']
    print(Block_ID)
    print(Address)
    print(Stored)
    input = Info(Block_ID, Address, Stored, None)
    newDataNode, block_data = dataNode.duplicate(input)
    if newDataNode is not None:
        requests.put(newDataNode + '/Block',
                     json={
                         'Block_ID': Block_ID,
                         'Address': Address,
                         'Stored': Stored,
                         'Data': block_data
                     })
        return json.dumps({'success': True}), 200, {
            'ContentType': 'application/json'
        }
    if newDataNode is None:
        return json.dumps({
            'success': False,
            'Error_Message': 'Block Not Found'
        }), 404, {
            'ContentType': 'application/json'
        }
Esempio n. 20
0
def ExtractSift(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    frame_path = info['frame_path']
    pano_download_path = info['pano_download_path']
    pano_path = info['pano_path']
    frame_sift_path = info['frame_sift_path']
    pano_sift_path = info['pano_sift_path']

    frame_lst_name = frame_path + '/list.txt'
    pano_lst_name = pano_download_path + '/list.txt'
    frame_sift_lst_name = pano_path + '/frame_sift_lst.txt'
    pano_sift_lst_name = pano_path + '/pano_sift_lst.txt'

    WriteImageList(frame_path, frame_lst_name)
    WriteImageList(pano_download_path, pano_lst_name)

    command_1 = 'VisualSFM siftgpu %s' % frame_lst_name
    command_2 = 'VisualSFM siftgpu %s' % pano_lst_name
    subprocess.call(command_1, shell=True)
    subprocess.call(command_2, shell=True)

    command_1 = 'mv %s/*.sift %s' % (frame_path, frame_sift_path)
    command_2 = 'mv %s/*.sift %s' % (pano_download_path, pano_sift_path)
    subprocess.call(command_1, shell=True)
    subprocess.call(command_2, shell=True)

    GetSiftList(frame_sift_path, frame_sift_lst_name)
    GetSiftList(pano_sift_path, pano_sift_lst_name)
    os.remove(frame_lst_name)
    os.remove(pano_lst_name)
Esempio n. 21
0
def storeBlock():
    print('---- TEST Add -----')
    Block_ID = request.json['Block_ID']
    Address = request.json['Address']
    Stored = request.json['Stored']
    Data = request.json['Data']
    print(Block_ID)
    print(Address)
    print(Stored)
    #print(Data)
    # create Info class input
    input = Info(Block_ID, Address, Stored, Data)
    # call the dataNode received method to store data.
    # This should return another data node to send data.
    otherDataNode, stored_data = dataNode.received(input)
    report = dataNode.getBlockReport()
    if otherDataNode is not None:
        requests.put(otherDataNode + '/Block',
                     json={
                         'Block_ID': Block_ID,
                         'Address': Address,
                         'Stored': stored_data,
                         'Data': Data
                     })
        requests.put(NAME_NODE_IP + '/BlockReport',
                     json={
                         'dn_ip': MY_IP,
                         'dn_block_report': report
                     })
    return json.dumps({'success': True}), 200, {
        'ContentType': 'application/json'
    }
Esempio n. 22
0
def Merge(ID):
    print ID
    info = Info.GetVideoInfo(ID)
    f_name = info['match_path'] + '/' + name
    f = open(f_name, 'r')
    data = json.load(f)
    f.close()
    key_lst = sorted(data.keys())
    pano_lst = []
    for key in key_lst:
        loc = data[key]
        print key
        try:
            panoid = GSV.getIDbyloc(lat=loc[0], lon=loc[1])
        except:
            data.pop(key)
            continue
        #print panoid
        if panoid is None:
            data.pop(key)
            continue
        elif not panoid in pano_lst:
            pano_lst.append(panoid)
            try:
                loc = GSV.getLocationbyID(panoid)
                data[key] = [float(loc[0]), float(loc[1])]
            except:
                data.pop(key)
                continue
        else:
            data.pop(key)
    f = open(info['match_path'] + '/google_info.json', 'w')
    f.write(json.dumps(data, indent=4))
    f.close()
Esempio n. 23
0
def CheckState(ID):
    info = Info.GetVideoInfo(ID)
    rigid_f = info['deep_match_path'] + '/rigid_distance_result.json'
    affine_f = info['deep_match_path'] + '/affine_distance_result.json'
    ourmethod_f = info['deep_match_path'] + '/distance_result.json'
    func = os.path.isfile
    if func(rigid_f) and func(affine_f) and func(ourmethod_f):
        return True
    return False
def CheckState(ID):
    info = Info.GetVideoInfo(ID)
    deep_f = info['deep_match_path'] + '/distance_result.json'
    hog_f = info['hog_match_path'] + '/distance_result.json'
    dsift_f = info['dsift_match_path'] + '/distance_result.json'
    func = os.path.isfile
    if func(deep_f) and func(hog_f) and func(dsift_f):
        return True
    return False
Esempio n. 25
0
def Merge(ID):
    info = Info.GetVideoInfo(ID)
    f1_name = Info.Get3DRansacFileName(info)
    subprocess.call('cp %s %s/ransac_3D_result_old.json' %
                    (f1_name, info['match_path']),
                    shell=True)
    f2_name = info['match_path'] + '/timeline.json'
    f1 = open(f1_name, 'r')
    f2 = open(f2_name, 'r')
    data = json.load(f1)
    tim = json.load(f2)
    data['id'] = tim['id']
    data['time'] = tim['time']
    f1.close()
    f2.close()
    f1 = open(f1_name, 'w')
    f1.write(json.dumps(data, indent=4))
    f1.close()
Esempio n. 26
0
def join_service(appeui, appkey):
    print("======================")
    appnonce = Info.get_appnonce()
    #appnonce = 1537598872
    challenge = calculate_challenge.get_challenge(appeui, appkey, appnonce)
    joindata = '{\"cmd\":\"join\",\"cmdseq\":%d,\"appeui\":\"%s\",\"appnonce\":%d,\"challenge\":\"%s\"}' % (
        getcmdseq(), appeui, appnonce, challenge)
    start_send(joindata)
    print("======================")
Esempio n. 27
0
def welcome():
    pygame.init()

    # 这是一个游戏的界面的设置

    GOLD = 255, 255, 0
    welcome_str_font = pygame.freetype.Font("Sofadione.ttf", 36)

    welcome_info = Info.Info()
    welcome_info.welcome_init()

    while True:
        welcome_info.screen.fill((0, 0, 0))
        welcome_info.screen.blit(welcome_info.welcome_image, (0, 0))
        welcome_str_font.render_to(welcome_info.screen, (80, 430),
                                   "Player Vs Player",
                                   fgcolor=GOLD,
                                   size=welcome_info.welcome_str_rect1_size)
        welcome_str_font.render_to(welcome_info.screen, (50, 480),
                                   "Player Vs Computer",
                                   fgcolor=GOLD,
                                   size=welcome_info.welcome_str_rect2_size)
        welcome_str_font.render_to(welcome_info.screen, (180, 530),
                                   "QUIT",
                                   fgcolor=GOLD,
                                   size=welcome_info.welcome_str_rect3_size)
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN and (
                    467 >= pygame.mouse.get_pos()[1] >= 427):
                welcome_info.welcome_str_rect1_size = 30
            elif event.type == pygame.MOUSEBUTTONUP and (
                    467 >= pygame.mouse.get_pos()[1] >= 427):
                welcome_info.welcome_str_rect1_size = 40
                welcome_info.mode = 4
                names = choice.choice(welcome_info.mode)
                return names

            elif event.type == pygame.MOUSEBUTTONDOWN and (
                    516 >= pygame.mouse.get_pos()[1] >= 486):
                welcome_info.welcome_str_rect2_size = 30
            elif event.type == pygame.MOUSEBUTTONUP and (
                    516 >= pygame.mouse.get_pos()[1] >= 486):
                welcome_info.welcome_str_rect2_size = 40
                welcome_info.mode = 1
                names = choice.choice(welcome_info.mode)
                return names
            elif event.type == pygame.MOUSEBUTTONDOWN and (
                    562 >= pygame.mouse.get_pos()[1] >= 522):
                welcome_info.welcome_str_rect3_size = 30
            elif event.type == pygame.MOUSEBUTTONUP and (
                    562 >= pygame.mouse.get_pos()[1] >= 522):
                welcome_info.welcome_str_rect3_size = 40
                sys.exit()
        pygame.display.update()
Esempio n. 28
0
def rename_column(sheet_title, old_column, new_column, spreadsheet=None):
    index = Info.getColumnIndex(spreadsheet, sheet_title, old_column)
    if index < 0:
        return
    col = Info.index_to_col(index)
    values = [
        [new_column],
    ]
    body = {'values': values}
    request = SHEET_SERVICE.spreadsheets().values().update(
        spreadsheetId=spreadsheet['id'],
        range="'{0}'!{1}1:{2}1".format(sheet_title, col, col),
        valueInputOption="USER_ENTERED",
        body=body)

    try:
        request.execute()
        RateLimiter.write_request()
    except HttpError as err:
        Log.err(spreadsheet, err, True)
Esempio n. 29
0
 def __init__(self, w, p, process):
     self.background = pygame.image.load('Assets/epitank.png')
     self.players = p
     self.bullets = Bullets.Bullets(w)
     self.keys = [KEYUP, KEYDOWN]
     self.DISPLAYSURF = w.getDisplay()
     self.window = w
     self.font = pygame.font.SysFont("monospace", 50)
     self.wait = self.font.render("Waiting for players...", 2, (255, 0, 0))
     self.IP_server = self.font.render(
         "IP_SERVER : " + str(Info.getinfoserver()['IP_ADDRESS']), 2,
         (255, 0, 0))
     self.PORT_server = self.font.render(
         "PORT_SERVER : " + str(Info.getinfoserver()['PORT']), 2,
         (255, 0, 0))
     self.tabpressed = False
     self.pressed = False
     self.lastkey = None
     self.DISPLAYSURF.blit(self.background, (0, 0))
     self.process = process
     pygame.display.update()
def Label(ID):
    info = Info.GetVideoInfo(ID)
    frame_lst = [
        x for x in sorted(os.listdir(info['frame_path'])) if x.endswith
    ]
    i = 0
    f = open(Info.GetMatchLstFileName(info), 'w')
    while True:
        f_name = info['frame_path'] + '/' + frame_lst[i]
        command = 'eog %s' % f_name
        subprocess.call(command, shell=True)
        panoid = raw_input('Pano ID : ')
        loc = GSV.getLocationbyID(panoid)
        print loc
        s = '%s\t%s\t%s\t%s\n' % (frame_lst[i], panoid, loc[0], loc[1])
        f.write(s)
        i += 10
        if i >= 125:
            f.close()
            return
    f.close()
Esempio n. 31
0
 def loadSinks(self):
     self.sink_list.addSink(Info.init())
     self.sink_list.addSink(Buttons.init())
     self.sink_list.addSink(Menus.init())
     self.sink_list.addSink(Images.init())
     self.sink_list.addSink(Layouts.init())
     self.sink_list.addSink(Lists.init())
     self.sink_list.addSink(Popups.init())
     self.sink_list.addSink(Tables.init())
     self.sink_list.addSink(Text.init())
     self.sink_list.addSink(Trees.init())
     self.sink_list.addSink(Frames.init())
     self.sink_list.addSink(Tabs.init())
Esempio n. 32
0
 def loadSinks(self):
     #self.sink_list.addSink(DataTree.init())
     #self.sink_list.addSink(RecipeSystemIFACE.init())
     self.sink_list.addSink(ADViewerIFACE.init())
     self.sink_list.addSink(RecipeViewer.init())
     self.sink_list.addSink(FITSStoreFACE.init())
     self.sink_list.addSink(DisplayIFACE.init())
     self.sink_list.addSink(Info.init())
     if False:
         self.sink_list.addSink(Buttons.init())
         self.sink_list.addSink(Menus.init())
         self.sink_list.addSink(Images.init())
         self.sink_list.addSink(Layouts.init())
         self.sink_list.addSink(Lists.init())
         self.sink_list.addSink(Popups.init())
         self.sink_list.addSink(Tables.init())
         self.sink_list.addSink(Text.init())
     if False: #preserving originaly order
         self.sink_list.addSink(Frames.init())
         self.sink_list.addSink(Tabs.init())
 def loadAlgorithms(self):
     self.Algorithm_list.addAlgorithm(Info.init())
     self.Algorithm_list.addAlgorithm(kMeans.init())
Esempio n. 34
0
import http
import re
import time
import os

if __name__ == '__main__':
    if Login.isLogin():
        print("已登录")
    else:
        account = input("请输入你的用户名\n>  ")
        secret = input("请输入你的密码\n>  ")
        Login.login(secret, account)

    index_page = Login.session.get('https://www.zhihu.com/#signin', headers=Login.headers) #主页
    #index_page = Login.session.get('https://www.zhihu.com/explore', headers=Login.headers)  #发现
    """
    f = open('C:\\Users\\penguin\\Desktop\\dump.txt', 'wb+')
    f.write(index_page.content)
    f.close()
    file = open('C:\\Users\\penguin\\Desktop\\dump.txt', 'r+', encoding= 'utf-8')
    """
    file_name = str(time.localtime()[0]) + '.' + str(time.localtime()[1]) + '.' + str(time.localtime()[2])\
    + '.' + str(time.localtime()[3]) + '.' + str(time.localtime()[4]) + '.' + str(time.localtime()[5])
    file_name += '_result.txt'
    path = os.getcwd() + '\\' + file_name
    file = open(path, 'w+', encoding='utf-8')
    p = re.compile(r'<h2 class=".*"><a class=".*" target=".*" href=".*">.*</a></h2>')
    for link in p.findall(index_page.text):
        if link != None:
            question_result = Info._question_info(link, file)
    file.close()
    new.tty = columns[6]
    new.stat = columns[7]
    new.start = columns[8]
    new.time = columns[9]
    new.command = columns[10]

    psaux.append(new)

print ("There are %d active processes" % (len(psaux)))

users = []
infos = []
for process in psaux:
    if(process.user not in users):
        users.append(process.user)
        info = Info()
        info.user = process.user
        info.cpu = float(process.cpu)
        info.mem = float(process.mem)
        infos.append(info)
    else:
        for info in infos:
            if(info.user == process.user):
                info.number += 1
                info.cpu += float(process.cpu)
                info.mem += float(process.mem)
                break


print ("...and %d users using your memory.\n" % (len(users)))