Exemplo n.º 1
0
    def get_library_list(self):
        self.__GET_login()
        wait(self.__delay)
        self.__POST_login()
        wait(self.__delay)

        url = self.__url_base + self.__config.get('url', 'url.myebooks')
        response = self.__session.get(url, headers=self.__headers)
        self.__log_response(response)
        soup = make_soup(response)
        for a in soup.findAll('div', attrs={'class': 'product-line unseen'}):
            print "Title:     " + a.attrs.get('title')
            print "Directory: " + a.attrs.get('title')[:-8].replace(' ', '_')
            # print a
            cover_url = a.find('img', attrs={'class': ' imagecache imagecache-thumbview'}).get('src').replace('thumbview', 'dotd_main_image')
            print "Cover URL: " "http:" + cover_url

            links = []
            for link in a.findAll('a', href=True):
                url = link.attrs.get('href')
                if not '#' in url:
                    links.append(url)
            for i in range(1, len(links)):
                if "cart" not in links[i] or not '#' or None:
                    if  links[i].split("/")[-1] == 'pdf':
                        print "Download pdf:   " + self.__url_base + links[i]
                    elif links[i].split("/")[-1] == 'epub':
                        print "Download epub:   " + self.__url_base + links[i]
                    elif links[i].split("/")[-1] == 'mobi':
                        print "Download mobi:   " + self.__url_base + links[i]
                    else:
                        print "Download extras:   " + self.__url_base + links[i]
Exemplo n.º 2
0
 def exec_container(self, cmd, stream=True):
     id = docker_client.exec_create(self.container_name, cmd)
     if stream:
         wait(docker_client.exec_start(exec_id=id, stream=True))
     else:
         docker_client.exec_start(exec_id=id)
     return self
Exemplo n.º 3
0
    def runNewsletter(self, currentNewsletterUrl):
        """
        """

        soup = self.__GET_login(currentNewsletterUrl)
        self.__parseNewsletterBookInfo(soup)
        wait(self.__delay, self.__dev)
        self.__GET_claim()
        wait(self.__delay, self.__dev)
Exemplo n.º 4
0
 def build(self, fail_if_exists=True):
     if self.exists:
         if fail_if_exists:
             raise RuntimeError("Image '{}' already exists".format(self.image_name))
     else:
         self.log.info("Building image {}".format(self.image_name))
         with self.source.get_docker_context() as context:
             wait(docker_client.build(path=context, tag=self.image_name, rm=True))
     return self
Exemplo n.º 5
0
def load_all_courses(driver, wait_time=5):
    switch_to_courses(driver, 'Courses')
    while True:
        try:
            driver.execute_script(
                "window.scrollTo(0, document.body.scrollHeight);")
            driver.find_element_by_xpath(
                '//a[@class="button button--outlined"]').click()
            utils.wait(wait_time)
        except:
            break
    driver.execute_script("window.scrollTo(0, 0);")
Exemplo n.º 6
0
def shoot(prev, new):
    """Animate a transition with a flying star."""
    d = 0.05
    icon = "*"
    length = max(len(prev), len(new))

    for pos in range(0, length, 2):
        padding = max(length - pos - 1 - len(prev), 0)
        old = prev[-(length - pos - padding):]
        yield wait(d, new[:pos] + ' ' * padding + old)

    yield wait(1, new.lstrip())
Exemplo n.º 7
0
Arquivo: Map.py Projeto: papay0/Path
 def mark_at_position_and_display(self, line, column, map):
     if self.previous_position:
         previous_position_line, previous_position_column = self.previous_position
         if not self.is_door(previous_position_line,
                             previous_position_column):
             self.map[previous_position_line][
                 previous_position_column] = '✨'
     self.previous_position = (line, column)
     if not self.is_door(line, column):
         self.map[line][column] = self.path_char
     wait(1)
     clear()
     self.print_map(map)
Exemplo n.º 8
0
 def __init__(self, modem, write_q, log):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     self._stop_event = threading.Event()
     self.name = 'ModemWriteThread'
     self._modem = modem
     self._data_q = write_q
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 9
0
def process_order(cart):
    global Inventory
    tempInventory = Inventory
    wait(operator.ge, 14, .5)
    for item in cart:
        if Inventory[item['type']] <= 0:
            raise Exception("Not enough inventory for " + item['type'])
        else:
            tempInventory[item['type']] -= 1
            print 'Success: ' + item[
                'type'] + ' was purchased, remaining stock is ' + str(
                    tempInventory[item['type']])
    Inventory = tempInventory
Exemplo n.º 10
0
 def build(self, fail_if_exists=True):
     if self.exists:
         if fail_if_exists:
             raise RuntimeError("Image '{}' already exists".format(
                 self.image_name))
     else:
         self.log.info("Building image {}".format(self.image_name))
         with self.source.get_docker_context() as context:
             wait(
                 docker_client.build(path=context,
                                     tag=self.image_name,
                                     rm=True))
     return self
Exemplo n.º 11
0
 def _execute_job(self, job_info):
     if self._mount_drive():
         job = StoreFileJob(job_info.src_file_name,
                             job_info.process_mne,
                             job_info.tmp_path,
                             job_info.compress,
                             self._log)
         while job.is_running():
             utils.wait(0.25)   
     else:                                
         self._log.error('Write failed.  USB flash drive is not mounted.')
         # Delete the temp file.  StoreFileJob usually does it.
         utils.delete_file(job_info.tmp_path, self._log)
Exemplo n.º 12
0
 def __init__(self, sock_h, log, exit_callback=None):
     threading.Thread.__init__(self)
     self._sock_h = sock_h
     self._log = log
     self._exit_callback = exit_callback
     self.setDaemon(False)
     self._stop_event = threading.Event()
     self.name = 'ClientConnection thread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 13
0
 def _transmit_pkt(self, pkt):
     """ Transmit a packet in chunks so other threads
     have a chance to run while transmitting a big packet
     """
     self._log.info('Started transmitting %s', pkt.type_str())
     self._log.info(''.join(['\n', pkt.str()]))
     pkt_buf = pkt.get_pkt_buf()
     block_size = 1152
     while (len(pkt_buf) > 0) and (not self._stop_event.isSet()):
         self._port.write(pkt_buf[0:block_size])
         pkt_buf = pkt_buf[block_size:]
         utils.wait(0.1)
     if not self._stop_event.isSet():
         self._log.info('Finished transmitting %s', pkt.type_str())
Exemplo n.º 14
0
 def __init__(self, data_file_path, compress, log, exit_callback=None):
     """
     """
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._data_file_path = data_file_path
     self._compress = compress
     self._log = log
     self.name = 'SaveFileThread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 15
0
 def __init__(self, log, serial_port, exit_callback=None):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     self._port = serial_port
     self._exit_callback = exit_callback
     self._pkt_q = Queue.Queue()
     self._stop_event = threading.Event()
     self.name = 'TxDataThread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 16
0
    def runDaily(self):
        """
        Running get free ebook daily
        """
        if self.__dev:
            loginUrl = self.__url_base + self.__config.get(
                'url', 'url.loginGet')
        else:
            loginUrl = self.__url_base + self.__config.get('url', 'url.login')

        self.info['landingPageUrl'] = loginUrl

        soup = self.__GET_login(loginUrl)
        wait(self.__delay, self.__dev)

        if self.__dev:
            loginUrl = self.__url_base + self.__config.get(
                'url', 'url.loginPost')

        self.__POST_login(loginUrl)
        wait(self.__delay, self.__dev)
        self.__parseDailyBookInfo(soup)
        wait(self.__delay, self.__dev)
        self.__GET_claim()
        wait(self.__delay, self.__dev)
Exemplo n.º 17
0
 def __init__(self, sock_h, base_rpc_server, log, exit_callback):
     threading.Thread.__init__(self)
     self._sock_h = sock_h
     self._base_rpc_server = base_rpc_server
     self._log = log
     self._exit_callback = exit_callback
     self._read_q = sock_h.get_read_q()
     self._write_q = sock_h.get_write_q()
     self._stop_event = threading.Event()
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 18
0
 def __init__(self, host, port, log=None):
     threading.Thread.__init__(self)
     self._log = log
     self.setDaemon(False)
     self._stop_event = threading.Event()
     self._host = host
     self._port = port
     self.name = ''.join(
         ('XMLRPC server thread (', self._host, ':', str(self._port), ')'))
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 19
0
def _run_proxy(log):
    """
        Run the server proxy until terminated
        via KeyboardInterrupt or XMLRPC command
    """
    log.info('')
    log.info('****** Starting server proxy ******')
    
    xfer_rec = XferRec(log)
    
    try:
        modem_svr_connector = ModemSvrConnector(xfer_rec, log)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)
        
    try:
        xmlrpc_thread = XMLRPCThread('localhost',
                            svr_proxy_config.XMLRPC_port, xfer_rec, log)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)
        
    while True:
        try:
            utils.wait(0.5)
            if not modem_svr_connector.is_running():
                break
            if not xmlrpc_thread.is_running():
                log.error('XMLRPC server thread died unexpectedly')
                break
        except KeyboardInterrupt:
            if svr_proxy_config.accept_sigint:
                log.info('Got SIGINT (shutting down)')
                break
            else:
                log.info('Got SIGINT ignored)')
        except:
            # handle all unexpected application exceptions
            exc_type, exc_value, exc_traceback = sys.exc_info()
            utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
            sys.exit(1)
                   
    modem_svr_connector.stop()
    xmlrpc_thread.stop()
    utils.wait_for_child_threads()
    log.info('****** Exiting server proxy ******')
Exemplo n.º 20
0
def _run_mgr(log):
    """
        Run the hardware manager until terminated
    """
    global subprocess_lock

    log.info('')
    log.info('****** Starting hardware manager ******')
    subprocess_lock = utils.Lock(log)
    _init_status()
    _init_digital_IO(log)
    _init_adc_params(log)

    try:
        console = SockConsole('localhost', hw_mgr_config.console_port, log)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)
    try:
        xmlrpc_thread = XMLRPCThread('localhost', hw_mgr_config.XMLRPC_port,
                                     console, log)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)

    while True:
        try:
            utils.wait(0.5)
            if not console.is_running():
                log.error('Console thread died unexpectedly')
                break
            if not xmlrpc_thread.is_running():
                log.error('XMLRPC server thread died unexpectedly')
                break
        except KeyboardInterrupt:
            if hw_mgr_config.accept_sigint:
                log.info('Got SIGINT (shutting down)')
                break
            else:
                log.info('Got SIGINT (ignored)')
        except Exception, e:
            # handle all unexpected application exceptions
            print '*** Unexpected exception in hw_mgr: %s' % e
            exc_type, exc_value, exc_traceback = sys.exc_info()
            utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
            sys.exit(1)
            break
Exemplo n.º 21
0
 def __init__(self, log, exit_callback=None):
     """
     """
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     self._exit_callback = exit_callback
     self._job_queue = Queue.Queue()
     self._stop_event = threading.Event()
     self.name = 'Dispatcher'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 22
0
 def enter_title(self, task=None):
     """Obtain name of task"""
     print("Enter task title")
     if task:
         print('Current: {}'.format(task.title))
     title = input("What is the name?  ")
     try:
         if not title:
             raise ValueError("Title cannot be empty.")
     except ValueError as err:
         utils.print_error(err)
         utils.wait()
         return self.enter_title()
     else:
         return title
Exemplo n.º 23
0
 def __init__(self, host, port, log, exit_callback=None):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     self._exit_callback = exit_callback
     self._host = host
     self._port = port
     self._children = []
     self._stop_event = threading.Event()
     self.name = 'BaseRPCServer thread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 24
0
 def __init__(self, log, exit_callback=None):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     self._host = 'localhost'
     self._port = modem_svr_config.client_port
     self._exit_callback = exit_callback
     self.sock = None
     self._stop_event = threading.Event()
     self.name = 'SvrProxyConnector thread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 25
0
 def __init__(self, log, xmlrpc_thread, exit_callback=None):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._log = log
     xmlrpc_thread.set_rudics_conn_thread(self)
     self._modem = None
     self._svr_proxy_connector = None
     self._rudics_svr_proxy_connection = None
     self._stop_event = threading.Event()
     self.name = 'RUDICSSvrProxyConnector thread'
     self._exit_callback = exit_callback
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 26
0
 def _transmit(self):
     while not self._stop_event.isSet():
         if not self._hf_power_is_on():
             self._enter_receive_mode()
             self._store_rx_buf()
             self._change_state('waiting_for_power_on')
             return
         if not self._in_transmit_window():
             #self._log_port_rx_buf()
             self._port.flushInput()  # Toss test msg echos
             self._enter_receive_mode()
             self._change_state('receiving')
             return
         self._send_test_msg()
         utils.wait(1)
     self._enter_receive_mode()
Exemplo n.º 27
0
 def _receive(self):
     while not self._stop_event.isSet():
         if not self._hf_power_is_on():
             self._store_rx_buf()
             self._change_state('waiting_for_power_on')
             return
         if self._in_transmit_window():
             utils.wait(hf_mgr_config.tx_dead_time)
             self._enter_transmit_mode()
             self._change_state('transmitting')
             return
         bytes_avail = self._port.inWaiting()
         if bytes_avail > 0:
             rx_str = self._port.read(bytes_avail)
             self._rx_buf_list.append(rx_str)
         utils.wait(2)
Exemplo n.º 28
0
def get_video_url(driver, clip_url):

    # load the player
    utils.open_url(driver, clip_url)
    utils.wait(5)

    # pause the video
    control_bar = driver.find_element_by_class_name('hidden-bar')
    play_button = driver.find_element_by_id('play-control')
    ActionChains(driver).move_to_element(control_bar).click(
        play_button).perform()

    # get video url
    video_url = driver.find_element_by_tag_name('video').get_attribute('src')

    return video_url
Exemplo n.º 29
0
 def enter_minutes(self, task=None):
     """Obtain user-supplied task time in minutes"""
     print("Enter task time")
     if task:
         print('Current: {}'.format(task.minutes))
     minutes_str = input("Please enter minutes:  ")
     try:
         if not minutes_str:
             raise ValueError("Minutes cannot be empty.")
         minutes = int(minutes_str)
     except ValueError as err:
         utils.print_error(err)
         utils.wait()
         return self.enter_minutes()
     else:
         return round(minutes)
Exemplo n.º 30
0
 def __init__(self, host, log, exit_callback=None):
     threading.Thread.__init__(self)
     self._log = log
     self._exit_callback = exit_callback
     self.setDaemon(False)
     self._host = host
     self._port = global_config.file_server_port
     self._children = []
     self._children_lock = threading.Lock()
     self._stop_event = threading.Event()
     self.name = '%s ClientConnector thread'
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 31
0
 def __init__(self, modem_svr_sock_h, xfer_rec, log):
     threading.Thread.__init__(self)
     self.setDaemon(False)
     self._modem_svr_sock_h = modem_svr_sock_h
     self._xfer_rec = xfer_rec
     self._log = log
     self._stop_event = threading.Event()
     self.name = 'ModemSvrConnection thread'
     self._modem_svr_proxy = None
     self._children = []
     self._children_lock = threading.Lock()
     self._running = False
     self._started = False
     self.start()
     while not self._started:
         utils.wait(0.05)
Exemplo n.º 32
0
def run_server(log, use_modem):
    """
        Run the modem server until terminated
        via KeyboardInterrupt or XMLRPC command
    """
    log.info('')
    log.info('****** Starting modem server ******')

    try:
        xmlrpc_thread = XMLRPCThread('localhost', modem_svr_config.XMLRPC_port,
                                     log)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)

    try:
        rudics_conn = RUDICSSvrProxyConnector(log, xmlrpc_thread)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)
        sys.exit(1)

    while True:
        try:
            utils.wait(0.5)
            if not rudics_conn.is_running():
                break
            if not xmlrpc_thread.is_running():
                log.error('XMLRPC thread died unexpectedly')
                break
        except KeyboardInterrupt:
            if modem_svr_config.accept_sigint:
                log.info('Got SIGINT (shutting down)')
                break
            else:
                log.info('Got SIGINT (ignored)')
        except:
            # handle all unexpected application exceptions
            exc_type, exc_value, exc_traceback = sys.exc_info()
            utils.log_exc_traceback(exc_type, exc_value, exc_traceback, log)

    rudics_conn.stop()
    xmlrpc_thread.stop()
    utils.wait_for_child_threads()
    log.info('****** Exiting modem server ******')
Exemplo n.º 33
0
 def _init_modem(self):
     """ Initialize the modem and leave it in receive mode.
         Return True if successful.
     """
     self._log.debug('Initializing modem...')
     if not self._cmd_and_response(self._sys_call_sign + self._newline,
                                   ':'):
         return False
     if not self._cmd_and_response('xflow off' + self._newline, ':'):
         return False
     if not self._cmd_and_response('port 1' + self._newline, ':'):
         return False
     if not self._cmd_and_response('reset' + self._newline, ':'):
         return False
     if not self._cmd_and_response('ba off' + self._newline, ':'):
         return False
     if not self._cmd_and_response('hbaud 300/300' + self._newline, ':'):
         return False
     if not self._cmd_and_response('shift modem' + self._newline, ':'):
         return False
     mark_freq = self._calc_mark_freq()
     if not self._cmd_and_response('mark ' + str(mark_freq) + self._newline,
                                   ':'):
         return False
     self._rx_buf_list.append("Mark = %s, " % str(mark_freq))
     if not self._cmd_and_response(
             'space ' + str(mark_freq + self._tone_shift) + self._newline,
             ':'):
         return False
     self._rx_buf_list.append("Space = %s" %
                              str(mark_freq + self._tone_shift) +
                              self._newline)
     if not self._cmd_and_response('xmitlvl 59/59' + self._newline, ':'):
         return False
     if not self._cmd_and_response(
             'MYSELCAL ' + self._sys_call_sign + self._newline, ':'):
         return False
     if not self._cmd_and_response('tor' + self._newline, 'STANDBY>'):
         return False
     self._go_to_cmd_mode()
     self._cmd_and_response('fec' + self._newline)
     utils.wait(1)
     self._port.flushInput()  # Toss fec echo
     self._enter_receive_mode()
     self._log.debug('Completed modem initialization')
     return True
Exemplo n.º 34
0
def _init_digital_IO(log):
    # DIO1 bit directions are set in the dio1 driver.
    # Set DIO2 bit directions.
    sbcctl_cmd('setdir DIO2 0 out', log)
    sbcctl_cmd('setdir DIO2 1 out', log)
    sbcctl_cmd('setdir DIO2 2 out', log)
    sbcctl_cmd('setdir DIO2 3 out', log)
    sbcctl_cmd('setdir DIO2 4 in', log)
    sbcctl_cmd('setdir DIO2 7 out', log)

    # Enable latched overcurrent detection
    sbcctl_cmd('setpin DIO2 7 off', log)

    # Clear possible overcurrent condition
    sbcctl_cmd('setpin DIO2 3 on', log)
    utils.wait(hw_mgr_config.over_cur_reset_dwell)
    sbcctl_cmd('setpin DIO2 3 off', log)
Exemplo n.º 35
0
def load_all_courses(driver, html_name, num_load=None):

    utils.open_url(driver, host + '/library/search')

    # switch to Course tab
    for elem in driver.find_elements_by_xpath('//li[@class="tab-list__item"]'):
        if elem.text == 'Courses':
            elem.click()

    # define target scraping section
    course_section = driver.find_element_by_xpath(
        '//div[@aria-selected="true"]')

    # expected number
    ncourse_expect = int(
        course_section.find_element_by_xpath(
            './/*[@class="l-search__results-page-info"]').text.split()[1])

    nload = 0
    if num_load:
        nload_max = num_load
    else:
        nload_max = (ncourse_expect // 25) + 3

    while nload < nload_max:
        courses = course_section.find_elements_by_xpath(
            './/li[@class="courses-list__item"]')
        ncourses = len(courses)
        utils.print_message('#load={}, ncourses={}'.format(nload, ncourses))

        nload += 1
        buttons = course_section.find_elements_by_xpath(
            './/a[@class="button button--outlined"]')
        if len(buttons) == 0:
            break

        buttons[0].click()
        utils.wait(3)

    # save html
    utils.save_html(driver, html_name)

    course_list = course_section.find_elements_by_xpath(
        './/li[@class="courses-list__item"]')
    utils.print_message('expect {} courses, loaded {}.'.format(
        ncourse_expect, len(course_list)))
Exemplo n.º 36
0
def mpd_np():
    """Display the mpd status via mpc."""
    try:
        status_output = Popen(["mpc", "status"], stdout=PIPE).communicate()[0]
    except OSError:
        yield wait(5, "mpc not installed :(")
        return

    result = ""

    lines = status_output.split("\n")
    if len(lines) < 3: # stopped
        yield wait(10, "MPD stopped")
    else:
        result += "MPD " + lines[1].split()[0] + " " + lines[0].strip()
        yield animate(10, result)
        yield animate(10, lines[1].split()[2])
Exemplo n.º 37
0
    def dump_all_library(self):
        # self.__GET_login()
        # wait(self.__delay)
        # self.__POST_login()
        # wait(self.__delay)

        url = self.__url_base + self.__config.get('url', 'url.myebooks')
        response = self.__session.get(url, headers=self.__headers)
        self.__log_response(response)
        soup = make_soup(response)
        for a in soup.findAll('div', attrs={'class': 'product-line unseen'}):
            log_info("[+] Downloading :     " + a.attrs.get('title'))
            #print "Downloading :     " + a.attrs.get('title')
            directory = a.attrs.get('title')[:-8].replace(' ', '_')
            directory = directory.encode('ascii', 'ignore').replace('/', '-')   ##### Error -  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position
            filename = directory

            #print "Directory: " + a.attrs.get('title')[:-8].replace(' ', '_')
            # print a
            # print "Cover URL: " "http:" + a.find('img', attrs={'class': ' imagecache imagecache-thumbview'}).get('src').replace('thumbview', 'dotd_main_image')

            cover_url = a.find('img', attrs={'class': ' imagecache imagecache-thumbview'}).get('src').replace('thumbview', 'dotd_main_image')
            download_file(self.__session, 'http:' + cover_url, self.__config.get('path', 'path.dumps') + '/' + directory, filename +'.jpg')

            links = []
            for link in a.findAll('a', href=True):
                url = link.attrs.get('href')
                if not '#' in url:
                    links.append(url)
            for i in range(1, len(links)):
                if "cart" not in links[i] or not '#' or None:
                    if  links[i].split("/")[-1] == 'pdf':
                    #    print "Download pdf:   " + self.__url_base + links[i]
                        download_file(self.__session, self.__url_base + links[i], self.__config.get('path', 'path.dumps') + '/' + directory, filename + '.pdf')
                    elif links[i].split("/")[-1] == 'epub':
                    #    print "Download epub:   " + self.__url_base + links[i]
                        download_file(self.__session, self.__url_base + links[i], self.__config.get('path', 'path.dumps') + '/' + directory, filename + '.epub')
                    elif links[i].split("/")[-1] == 'mobi':
                    #    print "Download mobi:   " + self.__url_base + links[i]
                        download_file(self.__session, self.__url_base + links[i], self.__config.get('path', 'path.dumps') + '/' + directory, filename + '.mobi')
                    else:
                    #    print "Download extras:   " + self.__url_base + links[i]
                        download_file(self.__session, self.__url_base + links[i], self.__config.get('path', 'path.dumps') + '/' + directory, filename +'.zip')

            wait(self.__delay)	
Exemplo n.º 38
0
def battery():
    """Display the battery status via acpi."""
    try:
        status_output = Popen(["acpi"], stdout=PIPE).communicate()[0]
    except OSError:
        yield wait(5, "battery status could not be determined.")
        return
    
    yield animate(10, status_output.split("\n")[0])
Exemplo n.º 39
0
 def run(self):
     """
     """
     self.__GET_login()
     wait(self.__delay)
     self.__POST_login()
     wait(self.__delay)
     self.__GET_claim()
     wait(self.__delay)
Exemplo n.º 40
0
    def runDaily(self):
        """
        """
        if self.__dev:
            loginUrl = self.__url_base + self.__config.get('url', 'url.loginGet')
        else:
            loginUrl = self.__url_base + self.__config.get('url', 'url.login')

        soup = self.__GET_login(loginUrl)
        wait(self.__delay, self.__dev)

        if self.__dev:
            loginUrl = self.__url_base + self.__config.get('url', 'url.loginPost')

        self.__POST_login(loginUrl)
        wait(self.__delay, self.__dev)
        self.__parseDailyBookInfo(soup)
        wait(self.__delay, self.__dev)
        self.__GET_claim()
        wait(self.__delay, self.__dev)
Exemplo n.º 41
0
 def run(self):
     interval = self.__class__.data['seconds per step']
     while True:
         utils.wait(interval)
         self.update()
Exemplo n.º 42
0
 def setUp(self):
     utils.wait()
     utils.debug_pid()
Exemplo n.º 43
0
                    '//*[@id="content"]/div[*]/div[3]/div/div[1]')\
                    .attr_list('photo-id')
            except grab.error.DataNotFound, ex:
                likes = []
        except grab.error.DataNotFound, ex:
            print 'Skip %s - %s' % (link, ex)
            continue
        except grab.error.GrabTimeoutError, ex:
            print 'Skip %s - %s' % (link, ex)
            continue
        try:
            if user_id:
                browser.execute_script(
                    '$.post(\
                        "http://tagbrand.com/followers/follow",\
                        {userId:%s});' % user_id)
                likes = likes[:2]
                for photo_id in likes:
                    if not utils.like_photo(browser, user_id, photo_id):
                        utils.like_photo(browser, user_id, photo_id)
        except selexcept.TimeoutException, ex:
            print 'Skip %s - %s' % (link, ex)
        except selexcept.WebDriverException:
            print 'Lost session? Try to reconnect'
            browser.quit()
            utils.wait(3)
            browser = utils.login(conf.LOGIN, conf.PASSWORD)

if __name__ == '__main__':
    follow()
Exemplo n.º 44
0
def wallclock():
    yield wait(5, "Wallclock")
    for i in range(10):
        yield wait(1, time.strftime("%H:%M:%S"))
        time.sleep(1)
Exemplo n.º 45
0
def load_and_uptime():
    """Display the output of uptime."""
    yield wait(10, Popen(["uptime"], stdout=PIPE).communicate()[0])
Exemplo n.º 46
0
 def pull(self):
     wait(docker_client.pull(self.source, stream=True))
     return self
Exemplo n.º 47
0
	def run(self):
		db = getDB()

		db.execute('SELECT CHECKTIME FROM VERSION')
		vt, = db.getone()
		while True:
			#--开始检查--
			#1. 先检查已经提交的是否完成了(这个在前面)
			try:
				getdata(db)
			except Exception,msg:
				print msg
			#2. 检查是否有需要提交的
			try:
				submit(db)
			except Exception,msg:
				print msg
			#3. 检查新版本
			if now() - vt > 1000*3600*12: #1天检查2次
				try:
					checkversion(db)
					vt = now()
				except Exception,msg:
					print msg
			wait(30000)

def runchecker():
	check = Checker()
	check.start()
	return check
Exemplo n.º 48
0
 def setUp(self):
     """Every test in this class will do this"""
     utils.wait()
     utils.debug_pid()
Exemplo n.º 49
0
def startup_animation():
    """Animate the startup of the script."""
    yield wait(1, "DWM Status Bar Animator")
    yield animate(1, "a silly script by timonator")