예제 #1
0
def steam_login(cwd=os.path.dirname(__file__)):
    login_fp = os.path.join(cwd, '../tools/EmailPass.txt')
    driver.find_element_by_xpath('//*[@id="steamAccountName"]').send_keys(
        get_input(login_fp, 0))
    driver.find_element_by_xpath('//*[@id="steamPassword"]').send_keys(
        get_input(login_fp, 1))
    driver.find_element_by_xpath('//*[@id="imageLogin"]').click()
예제 #2
0
파일: get_edf.py 프로젝트: zxmxyh/pyXPCS
def get_ccd(file, roi='none', avgt='none'):
    infos = get_input()
    filetest = os.path.exists(file)
    while filetest is False:
        print 'waiting for file ', file.split('/')[-1], ' ...'
        sleep(2)
        filetest = os.path.exists(file)
    f = open(file, 'r')
    header = f.read(1024)
    ccd = f.read()
    f.close()

    param = get_header_f(header)
    byte_order = param['ByteOrder']
    data_type = param['DataType']
    ncol = int(param['Dim_1'])  #in pixel units
    nrows = int(param['Dim_2'])  # in pixel units
    dim = ncol * nrows
    #   I_mon=int(param['mon'])
    I_mon = 1
    if avgt == 'none':
        #   t=float(param['sec']) # for old files
        #t=float(param['ccdtavg']) # for new files
        detector = infos['detector'].lower()
        if detector == 'medipix':
            t = float(param['time_of_frame'])  # for new files
        if (detector == 'princeton' or detector == 'andor'):
            t = float(param['time_of_day'])  # for new files
    else:
        t = float(
            avgt)  # for the medipix we have to give the time for the moment
    if byte_order == 'HighByteFirst':
        f1 = ">"
    else:
        f1 = "<"
    if data_type == 'UnsignedShort':
        f2 = "H"
        typ = "Int16"
    else:
        f2 = "L"
        typ = "Int32"
    format = f1 + dim * f2
    if roi == 'none':
        c = array(unpack(format, ccd))
        ccdimage = reshape(c, (nrows, ncol))
    else:
        ccdimage = get_roi(ccd, roi, ncol, nrows, typ, f1, f2)
    result = [ccdimage, I_mon, t]
    return result
예제 #3
0
파일: get_edf.py 프로젝트: Nikea/pyXPCS
def get_ccd(file,roi='none',avgt='none'):
   infos=get_input() 
   filetest=os.path.exists(file)
   while filetest is False:
      print 'waiting for file ', file.split('/')[-1], ' ...'
      sleep(2)
      filetest=os.path.exists(file)
   f = open(file,'r')
   header = f.read(1024)
   ccd=f.read()
   f.close()

   param = get_header_f(header)
   byte_order= param['ByteOrder']
   data_type= param['DataType']
   ncol=int(param['Dim_1']) #in pixel units
   nrows=int(param['Dim_2']) # in pixel units
   dim=ncol*nrows
#   I_mon=int(param['mon'])
   I_mon=1
   if avgt=='none':
#   t=float(param['sec']) # for old files
      #t=float(param['ccdtavg']) # for new files
      detector=infos['detector'].lower()
      if detector=='medipix': 
         t=float(param['time_of_frame']) # for new files
      if (detector=='princeton' or detector=='andor'): 
         t=float(param['time_of_day']) # for new files
   else:
      t=float(avgt) # for the medipix we have to give the time for the moment
   if byte_order=='HighByteFirst':
      f1=">"
   else:
      f1="<"
   if data_type=='UnsignedShort':
      f2="H"
      typ="Int16"
   else:
      f2="L"
      typ="Int32"
   format=f1+dim*f2
   if roi=='none':
      c= array(unpack(format, ccd))
      ccdimage=reshape(c,(nrows,ncol))
   else:
        ccdimage=get_roi(ccd,roi,ncol,nrows,typ,f1,f2)
   result= [ccdimage,I_mon,t]
   return result
예제 #4
0
from read_input import get_input
from assembunny import AssemBunny

if __name__ == "__main__":
    puzzle_input = get_input(23)
    ab = AssemBunny({'a': 7, 'b': 0, 'c': 0, 'd': 0})
    ab.parse_instructions(puzzle_input)

    print ab.registers

    puzzle_input_2 = get_input('23_ii')
    ab2 = AssemBunny({'a': 12, 'b': 0, 'c': 0, 'd': 0})
    ab2.parse_instructions(puzzle_input_2)

    print ab2.registers
예제 #5
0
        for nd in node_data[2:]:
            name = re.search('node-x\d+-y\d+', nd).group(0)
            storage = re.findall('\d+T', nd)
            size, used, avail = [ int(s.strip('T')) for s in storage]
            nodes[tuple(re.findall('\d+', name))] = Node(name, size, used, avail)
        return nodes

    def visualize_grid(self):
        coords = self.nodes.keys()
        ordered_coords = sorted(coords, key=lambda el: (int(el[0]), int(el[1])))
        rows, cols = zip(*ordered_coords)
        n_rows = max([int(r) for r in rows]) + 1
        n_cols = max([int(c) for c in cols]) + 1

        grid = []
        for i in range(0,n_rows):
            for j in range(0, n_cols):
                n = self.nodes[((str(i)),str(j))]
                grid.append('%s/%s ' % (n.used, n.size))
            grid.append('\n')

        return "".join(grid)

if __name__ == "__main__":
    puzzle_input = get_input(22)
    n = Node('node-x0-y0', 86, 73, 13)
    print n
    g = Grid(puzzle_input)
    print len(g.get_viable_pairs())
    print g.visualize_grid()
예제 #6
0
from assembunny import AssemBunny
from itertools import repeat


def first(iterable):
    return next(iter(iterable))


def repeating_signal(a,
                     instructions,
                     target_signal,
                     steps=10**6,
                     signal_len=100):
    signal = AssemBunny({
        'a': a,
        'b': 0,
        'c': 0,
        'd': 0
    }).parse_instructions(instructions, steps=steps)
    count = 0
    for i, (s, t) in enumerate(zip(signal, target_signal)):
        count = i
        if signal != t:
            return False
    return count >= signal_len


if __name__ == "__main__":
    first(a for a in range(0, 10**6)
          if repeating_signal(a, get_input(25), repeat((0, 1))))
예제 #7
0
            scrambled_input = rotate_n_steps(scrambled_input,
                                             -int(split_str[2]))
        if ins.startswith('rotate right'):
            scrambled_input = rotate_n_steps(scrambled_input,
                                             int(split_str[2]))
        if ins.startswith('rotate based'):
            scrambled_input = rotate_on_char_pos(scrambled_input,
                                                 split_str[-1])
        if ins.startswith('reverse'):
            scrambled_input = reverse_by_index(scrambled_input,
                                               int(split_str[2]),
                                               int(split_str[4]))
        if ins.startswith('move'):
            scrambled_input = move_by_index(scrambled_input, int(split_str[2]),
                                            int(split_str[5]))
    return scrambled_input


def reverse_scramble_password(scrambled, instructions):
    for p in permutations(scrambled):
        if parse_instructions(p, instructions) == scrambled:
            return "".join(p)


if __name__ == "__main__":
    instructions = get_input(21)
    puzzle_input = 'abcdefgh'

    print parse_instructions(puzzle_input, instructions)
    print reverse_scramble_password('fbgdceah', instructions)
예제 #8
0
        'video_dislikes',
        'video_comments',
        'video_duration',

        #all columns below are calculated in this script
        'sub_count_int',  #int
        'video_ad_sum',  #int
        'video_views_int',  #int
        'video_likes_int',  #int
        'video_dislikes_int',  #int
        'video_comments_int'  #int
    ]

    data_df = pd.DataFrame(columns=pd_columns)

    data_fn = get_input(input_fp, 1)
    data_fp = os.path.join(cwd, '../build/' + data_fn)
    data_textIO = open(data_fp, 'r')
    data_str = data_textIO.read()
    data_arr = []
    for dt in decode_stacked(data_str):
        data_df = data_df.append(pd.Series([
            dt['user_metrics']['current_date'],
            dt['user_metrics']['user_name'],
            dt['user_metrics']['sub_count_desc'],
            dt['ad_metrics']['panel_ad']['title'],
            dt['ad_metrics']['panel_ad']['href'],
            dt['ad_metrics']['video_ad']['length_desc'],
            dt['ad_metrics']['video_ad']['video_duration'],
            dt['ad_metrics']['video_ad']['href'],
            str(dt['ad_metrics']['ad_reasons']).strip('[]'),
예제 #9
0
        self.current_pos = self.initial_pos


def parse_input(data):
    parsed = [re.findall('\d+', l) for l in data]
    return [[p[0], int(p[1]), int(p[3])] for p in parsed]


def run(data):
    initial_t = -1
    disc_data = parse_input(data)
    discs = [Disc(*d) for d in disc_data]

    complete = False
    while not complete:
        [d.reset_position() for d in discs]
        initial_t += 1
        complete = all([
            d.update_n_times(initial_t + idx + 1) == 0
            for idx, d in enumerate(discs)
        ])
    return initial_t


if __name__ == "__main__":
    data = get_input(15)
    print run(data)

    data.append('Disc #7 has 11 positions; at time=0, it is at position 0.')
    print run(data)
예제 #10
0
#Driver presses space to toggle video pause/play
def toggle_pause(driver):
    """k is a hotkey for toggling the pause/play
    
    Arguments:
        driver {webdriver} -- chrome environment
    """
    ActionChains(driver) \
        .key_down('K') \
        .key_up('K') \
        .perform()

#Main method
if __name__ == "__main__":
    driver = get_chromedriver('../tools/chromedriver.exe', '../build/')
    driver.get(get_input(input_fp, 0))


    driver.implicitly_wait(5)
    user_metrics = get_metrics(driver, 'user')

    completed = False
    while not completed:
        try:
            driver.implicitly_wait(2)
            ad_metrics = get_metrics(driver, 'ad')
            video_metrics = get_metrics(driver, 'video')

            all_metrics = {
                "user_metrics" : user_metrics,
                "ad_metrics" : ad_metrics,
예제 #11
0
    values = []
    for i in range(len(names)):
        values.append(inp.__getattribute__(names[i]))
    units = [
        "m", "m", "", "", "m", "m", "deg", "deg", "x/c", "x/c", "y/b", "m", "",
        "deg", "m/s", "", ""
    ]
    write_list(pdf, "Input parameters:", (20, list_y), names, values, units)

    # Make output list
    names = [
        "Cl_max of airfoil", "Delta Cl_max", "Flap hinge location",
        "Flap deflection"
    ]
    values = [
        round(cl_max_airfoil, 3),
        round(Delta_cl_max, 3),
        round(flap_hinge_location, 3),
        round(flap_deflection, 3)
    ]
    units = ["", "", "x/c", "deg"]
    write_list(pdf, "Output parameters:", (110, list_y), names, values, units)

    pdf.output("pdf_out/" + planform_file_name + "_" +
               str(datetime.datetime.today())[:10] + ".pdf")


if __name__ == "__main__":
    inp = get_input("planforms/test_planform1.txt")
    write_pdf(inp, 1.2, 0.8, 0.5, "Test run", 45)
예제 #12
0
파일: Main.py 프로젝트: rkptrs/KBE
 def input(self):
     out = get_input("planforms/" + self.planform_file_name + ".txt")
     if out.valid:
         out = check_input(out, self.planform_file_name)
     return out