Exemple #1
0
 def download_task():
    
    # 3a. load the image. 
    new_image = db.query_image(ref) # disposed later
       
    # 3b. now that we've loaded a new image, the following method is
    #     passed back to the gui thread and run to update our gui 
    def update_image():
       
       # if somehow the image we just loaded is already in the cache,
       # take it out and dispose it.  this should be rare.    
       if ref in self.__image_cache:
          old_image = self.__image_cache[ref]
          del self.__image_cache[ref]
          if old_image:
             old_image.Dispose()
       
       # cache the new image, so we never have to load it again
       if new_image:
          self.__image_cache[ref] = new_image
       
       # if the __current_image_ref hasn't changed, switch this 
       # PictureBox to display that image.  otherwise, we already 
       # loading a new one, so don't do a pointless visual update.
       if ref == self.__current_image_ref:
          switchimage(new_image)
          
    utils.invoke(self, update_image, False) 
Exemple #2
0
 def __picture_box_clicked(self, sender, args):
    ''' This method is called whenever the user clicks on the pboxpanel. '''
    
    # this method causes the currently displayed page to change, either
    # forward or backward, as a result of the user left-clicking on the pbox
    mouse_hovered_state = self.__pbox_panel.get_mouse_hovered_state()
    if self.__current_book and args.Button == MouseButtons.Left \
          and mouse_hovered_state:
       
       # 1. calculate a new current page index, based on where use clicked
       if mouse_hovered_state == 'FL':
          self.__current_page = 0
       elif mouse_hovered_state == 'L':
          self.__current_page -= 1
       elif mouse_hovered_state == 'R':
          self.__current_page += 1
       elif mouse_hovered_state == 'FR':
          self.__current_page = self.__current_page_count-1
          
       self.__current_page = \
          min( self.__current_page_count-1, max(0, self.__current_page) )
       
       # grab the new page_image on the main ComicRack thread, because doing 
       # so accesses ComicRack's data.  then set it our own thread, because
       # doing so accesses our own data!  thread safety is fun.
       page_index = self.__current_page # a thread safety copy
       current_book = self.__current_book # a thread safety copy
       page_image = [None]
       def get_page():
          page_image[0] = current_book.create_image_of_page(page_index)
          def set_page():
             self.__pbox_panel.set_image(page_image[0]) # image may be None
             self.__pbox_panel.Refresh() # just in case nothing changed
          utils.invoke(self, set_page, False)
       utils.invoke( self.__scraper.comicrack.MainWindow, get_page, False )
Exemple #3
0
def fs_create(req, pool_name, name, size_bytes):
    pool_check(pool_name)

    full_path = os.path.join(pool_name, fs_path, name)

    if not os.path.exists(full_path):
        invoke([fs_cmd, 'subvolume', 'create', full_path])
    else:
        raise TargetdError(-53, 'FS already exists')
Exemple #4
0
            def get_page():
                page_image[0] = current_book.create_image_of_page(page_index)

                def set_page():
                    self.__pbox_panel.set_image(
                        page_image[0])  # image may be None
                    self.__pbox_panel.Refresh()  # just in case nothing changed

                utils.invoke(self, set_page, False)
Exemple #5
0
def fs_create(req, pool_name, name, size_bytes):
    pool_check(pool_name)

    full_path = os.path.join(pool_name, fs_path, name)

    if not os.path.exists(full_path):
        invoke([fs_cmd, 'subvolume', 'create', full_path])
    else:
        raise TargetdError(-53, 'FS already exists')
 def maybe_convert_seriesref_to_issue_ref(ref):
    if not ref in self.__series_cache:
       issue_ref = db.query_issue_ref(ref, self.__issue_num_hint_s)
       self.__series_cache[ref] = issue_ref if issue_ref else ref
          
    # 1b. go back to the application thread to do the actual ref change
    def change_ref():  
       self.__ref = self.__series_cache[ref]
       self.__update()
    utils.invoke(self.__coverpanel, change_ref, True)
            def maybe_convert_seriesref_to_issue_ref(ref):
                if not ref in self.__series_cache:
                    issue_ref = db.query_issue_ref(ref,
                                                   self.__issue_num_hint_s)
                    self.__series_cache[ref] = issue_ref if issue_ref else ref

                # 1b. go back to the application thread to do the actual ref change
                def change_ref():
                    self.__ref = self.__series_cache[ref]
                    self.__update()

                utils.invoke(self.__coverpanel, change_ref, True)
 def update_cache(): #runs on scheduler thread
    issue = db.query_issue(ref, True) \
       if type(ref) == IssueRef else None 
       
    def update_bmodel():  # runs on application thread
       bmodel = cache[ref]
       if issue and len(issue.image_urls_sl) > 1:
          for i in range(1, len(issue.image_urls_sl)):
             bmodel.add_new_ref(issue.image_urls_sl[i])
       bmodel.set_status('searched')
       self.__update() # recurse!
    utils.invoke(self, update_bmodel, True)
                def update_cache():  #runs on scheduler thread
                    issue = db.query_issue(ref, True) \
                       if type(ref) == IssueRef else None

                    def update_bmodel():  # runs on application thread
                        bmodel = cache[ref]
                        if issue and len(issue.image_urls_sl) > 1:
                            for i in range(1, len(issue.image_urls_sl)):
                                bmodel.add_new_ref(issue.image_urls_sl[i])
                        bmodel.set_status('searched')
                        self.__update()  # recurse!

                    utils.invoke(self, update_bmodel, True)
Exemple #10
0
def fs_snapshot(req, fs_uuid, dest_ss_name):
    fs = _get_fs_by_uuid(req, fs_uuid)

    if fs:
        source_path = os.path.join(fs['pool'], fs_path, fs['name'])
        dest_base = os.path.join(fs['pool'], ss_path, fs['name'])
        dest_path = os.path.join(dest_base, dest_ss_name)

        create_sub_volume(dest_base)

        if os.path.exists(dest_path):
            raise TargetdError(-53, "Snapshot already exists with that name")

        invoke([fs_cmd, 'subvolume', 'snapshot', '-r', source_path, dest_path])
 def close_threadsafe(self):
    '''
    A threadsafe method for closing this ComicForm and disposing of it's
    Application thread.   Note that closing the form with this method will
    NOT flag the ScraperEngine as cancelled.  Any other method of closing
    (user clicks on red x, the Close() method, etc) will flag cancel.
    '''
    
    def delegate():
       self.__cancel_on_close = False
       self.Close()
       self.Dispose()
    if not self.__already_closed:
       utils.invoke(self, delegate, True)
Exemple #12
0
def fs_snapshot(req, fs_uuid, dest_ss_name):
    fs = _get_fs_by_uuid(req, fs_uuid)

    if fs:
        source_path = os.path.join(fs['pool'], fs_path, fs['name'])
        dest_base = os.path.join(fs['pool'], ss_path, fs['name'])
        dest_path = os.path.join(dest_base, dest_ss_name)

        create_sub_volume(dest_base)

        if os.path.exists(dest_path):
            raise TargetdError(-53, "Snapshot already exists with that name")

        invoke([fs_cmd, 'subvolume', 'snapshot', '-r', source_path, dest_path])
Exemple #13
0
    def close_threadsafe(self):
        '''
      A threadsafe method for closing this ComicForm and disposing of it's
      Application thread.   Note that closing the form with this method will
      NOT flag the ScraperEngine as cancelled.  Any other method of closing
      (user clicks on red x, the Close() method, etc) will flag cancel.
      '''
        def delegate():
            self.__cancel_on_close = False
            self.Close()
            self.Dispose()

        if not self.__already_closed:
            utils.invoke(self, delegate, True)
Exemple #14
0
    def show_threadsafe(cls, *args):
        '''
      A threadsafe method for instantiating a new ComicForm on a NEW 
      Application thread, and then displaying it to the user.  The Application
      thread will shutdown and dispose automatically when the ComicForm is
      closed.  
      
      All given arguments will be passed to the new ComicForm's constructor.
      '''

        cls.newform = None

        def shower():
            with cls(*args) as form:
                Monitor.Enter(cls)
                try:
                    cls.newform = form
                    Monitor.Pulse(cls)
                finally:
                    Monitor.Exit(cls)

                def exception_handler(sender, event):
                    log.handle_error(event.Exception)
                Application.ThreadException +=\
                   ThreadExceptionEventHandler(exception_handler)
                Application.Run(form)  # start form on new App thread; blocks

        Monitor.Enter(cls)
        try:
            # starts a new thread, which will become the Application thread/ event
            # pump for the newly created ComicForm,
            Thread(ThreadStart(shower)).Start()
            Monitor.Wait(cls)
        finally:
            Monitor.Exit(cls)
        newform = cls.newform
        del cls.newform

        # make sure this method does not return until the newly created ComicForm
        # has actually been made visible and active.  see bug 139.
        def activate_form():
            # this call is probably not needed; the real trick here is that
            # invoking this method synchronously delays us until the form has
            # a nice, visible handle on-screen
            newform.Activate()

        utils.invoke(newform, activate_form, True)

        return newform
def discovery_wrapper(hostname=None,
                      discovery_method=None,
                      operation=None,
                      op_params=(),
                      discover=False):
    """
    Returns the iscsiadm command, with discovery mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "discoverydb"]
    if hostname:
        cmd.extend(["-p", hostname])
    if discovery_method:
        cmd.extend(["-t", discovery_method])
    if operation:
        cmd.extend(["-o", operation])
        if op_params:
            cmd.extend(["-n", "discovery.sendtargets.auth.%s" % op_params[0]])
            cmd.extend(["-v", op_params[1]])
    elif discover:
        cmd.extend(["-D", "-P", "1"])
    return_code, output_success, output_failure = invoke(cmd, False)
    if return_code:
        try:
            error_string = output_failure.splitlines()[0].split(" ", 1)[-1]
            error_string = error_string.strip()
            # error_string extracts the text after "iscsiadm: " of the
            # first line of e.output
            error_code = get_error_code(return_code)
            raise TargetdError(error_code, error_string)
        except IndexError:
            raise TargetdError(DISCOVERY_RECORD_NOT_FOUND,
                               "No discovery records found")
    return output_success
Exemple #16
0
def discovery_wrapper(hostname=None, discovery_method=None, operation=None,
                      op_params=(), discover=False):
    """
    Returns the iscsiadm command, with discovery mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "discoverydb"]
    if hostname:
        cmd.extend(["-p", hostname])
    if discovery_method:
        cmd.extend(["-t", discovery_method])
    if operation:
        cmd.extend(["-o", operation])
        if op_params:
            cmd.extend(["-n", "discovery.sendtargets.auth.%s" % op_params[0]])
            cmd.extend(["-v", op_params[1]])
    elif discover:
        cmd.extend(["-D", "-P", "1"])
    return_code, output_success, output_failure = invoke(cmd, False)
    if return_code:
        try:
            error_string = output_failure.splitlines()[0].split(" ", 1)[-1]
            error_string = error_string.strip()
            # error_string extracts the text after "iscsiadm: " of the
            # first line of e.output
            error_code = get_error_code(return_code)
            raise TargetdError(error_code, error_string)
        except IndexError:
            raise TargetdError(DISCOVERY_RECORD_NOT_FOUND,
                               "No discovery records found")
    return output_success
def node_wrapper(targetname=None,
                 hostname=None,
                 operation="",
                 op_params=(),
                 login_out=None):
    """
    Returns the iscsiadm command, with node mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "node", "-P", "1"]
    if targetname:
        cmd.extend(["-T", targetname])
    if hostname:
        cmd.extend(["-p", hostname])
    if operation:
        cmd.extend(["-o", operation])
        if op_params:
            cmd.extend(["-n", "node.session.auth.%s" % op_params[0]])
            cmd.extend(["-v", op_params[1]])
    elif login_out:
        if login_out == "login":
            cmd.append("--login")
        if login_out == "logout":
            cmd.append("--logout")
    error_code, output_success, output_failure = invoke(cmd, False)
    if error_code != 0:
        error_string = output_failure.splitlines()[0].split(" ", 1)[-1].strip()
        # error_string extracts the text after "iscsiadm: " of the
        # first line of e.output
        error_code = get_error_code(error_code)
        raise TargetdError(error_code, error_string)
    return output_success
Exemple #18
0
def node_wrapper(targetname=None, hostname=None, operation="",
                 op_params=(), login_out=None):
    """
    Returns the iscsiadm command, with node mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "node", "-P", "1"]
    if targetname:
        cmd.extend(["-T", targetname])
    if hostname:
        cmd.extend(["-p", hostname])
    if operation:
        cmd.extend(["-o", operation])
        if op_params:
            cmd.extend(["-n", "node.session.auth.%s" % op_params[0]])
            cmd.extend(["-v", op_params[1]])
    elif login_out:
        if login_out == "login":
            cmd.append("--login")
        if login_out == "logout":
            cmd.append("--logout")
    error_code, output_success, output_failure = invoke(cmd, False)
    if error_code != 0:
        error_string = output_failure.splitlines()[0].split(" ", 1)[-1].strip()
        # error_string extracts the text after "iscsiadm: " of the
        # first line of e.output
        error_code = get_error_code(error_code)
        raise TargetdError(error_code, error_string)
    return output_success
 def show_threadsafe(cls, *args):
    '''
    A threadsafe method for instantiating a new ComicForm on a NEW 
    Application thread, and then displaying it to the user.  The Application
    thread will shutdown and dispose automatically when the ComicForm is
    closed.  
    
    All given arguments will be passed to the new ComicForm's constructor.
    '''
    
    cls.newform = None
    def shower():                                                           
       with cls(*args) as form:
          Monitor.Enter(cls)
          try:
             cls.newform = form
             Monitor.Pulse(cls)
          finally:
             Monitor.Exit(cls)
          def exception_handler(sender, event):
             log.handle_error(event.Exception)  
          Application.ThreadException +=\
             ThreadExceptionEventHandler(exception_handler)
          Application.Run(form) # start form on new App thread; blocks
    
    Monitor.Enter(cls)
    try:
       # starts a new thread, which will become the Application thread/ event
       # pump for the newly created ComicForm,
       Thread(ThreadStart(shower)).Start()
       Monitor.Wait(cls)
    finally:
       Monitor.Exit(cls)
    newform = cls.newform
    del cls.newform
     
    # make sure this method does not return until the newly created ComicForm
    # has actually been made visible and active.  see bug 139.
    def activate_form():
       # this call is probably not needed; the real trick here is that 
       # invoking this method synchronously delays us until the form has
       # a nice, visible handle on-screen
       newform.Activate()
    utils.invoke(newform, activate_form, True)
    
    return newform
Exemple #20
0
 def exports():
     """
     Return list of exports
     """
     rc = []
     ec, out, error = invoke([Nfs.CMD, '-v'])
     rc = Export.parse_exportfs_output(out)
     return rc
Exemple #21
0
    def __start_scrape(self, book, num_remaining):
        '''
      This method gets called once for each comic that the ScrapeEngine is 
      scraping; the call happens just before the scrape begins.  The method 
      updates all necessary graphical components to reflect the current scrape.
      
      'book' -> the comic book object that is about to be scraped
      'num_remaining' -> the # of books left to scrape (including current one) 
      '''

        # 1. obtain a nice filename string to put into out Label
        book_name = Path.GetFileName(
            book.path_s.strip())  # path_s is never None
        fileless = book_name == ""
        if fileless:
            # 1a. this is a fileless book, so build up a nice, detailed name
            book_name = book.series_s
            if not book_name:
                book_name = "<" + i18n.get("ComicFormUnknown") + ">"
            book_name += (' #' + book.issue_num_s) if book.issue_num_s else ''
            book_name += (' ({0} {1})'.format(
               i18n.get("ComicFormVolume"), sstr(book.volume_year_n) ) ) \
               if book.volume_year_n >= 0 else (' ('+sstr(book.pub_year_n) +')') \
               if book.pub_year_n >= 0 else ''

        # 2. obtain a copy of the first (cover) page of the book to install
        page_image = book.create_image_of_page(0)
        page_count = book.page_count_n

        # 3. install those values into the ComicForm.  update progressbar.
        def delegate():
            # NOTE: now we're on the ComicForm Application Thread
            self.__current_book = book
            self.__current_page = 0
            self.__current_page_count = page_count
            self.__label.Text = i18n.get("ComicFormScrapingLabel") + book_name
            self.__pbox_panel.set_image(page_image)  # cover image may be None
            self.__progbar.PerformStep()
            self.__progbar.Maximum = self.__progbar.Value + num_remaining
            self.__cancel_button.Text=\
               i18n.get("ComicFormCancelButton").format(sstr(num_remaining))
            self.Update()

        utils.invoke(self, delegate, False)
   def __start_scrape(self, book, num_remaining):
      '''
      This method gets called once for each comic that the ScrapeEngine is 
      scraping; the call happens just before the scrape begins.  The method 
      updates all necessary graphical components to reflect the current scrape.
      
      'book' -> the comic book object that is about to be scraped
      'num_remaining' -> the # of books left to scrape (including current one) 
      '''

      # 1. obtain a nice filename string to put into out Label    
      book_name = Path.GetFileName(book.path_s.strip()) # path_s is never None
      fileless = book_name == ""
      if fileless:
         # 1a. this is a fileless book, so build up a nice, detailed name
         book_name = book.series_s 
         if not book_name:
            book_name = "<" + i18n.get("ComicFormUnknown") + ">"
         book_name += (' #' + book.issue_num_s) if book.issue_num_s else ''
         book_name += (' ({0} {1})'.format(
            i18n.get("ComicFormVolume"), sstr(book.volume_year_n) ) ) \
            if book.volume_year_n >= 0 else (' ('+sstr(book.pub_year_n) +')') \
            if book.pub_year_n >= 0 else ''
        
      # 2. obtain a copy of the first (cover) page of the book to install
      page_image = book.create_image_of_page(0)
      page_count = book.page_count_n
       
      # 3. install those values into the ComicForm.  update progressbar.        
      def delegate():
         # NOTE: now we're on the ComicForm Application Thread
         self.__current_book = book
         self.__current_page = 0
         self.__current_page_count = page_count
         self.__label.Text = i18n.get("ComicFormScrapingLabel") + book_name
         self.__pbox_panel.set_image(page_image) # cover image may be None
         self.__progbar.PerformStep()
         self.__progbar.Maximum = self.__progbar.Value + num_remaining
         self.__cancel_button.Text=\
            i18n.get("ComicFormCancelButton").format(sstr(num_remaining))
         self.Update()
      utils.invoke(self, delegate, False)
Exemple #23
0
def fs_clone(req, fs_uuid, dest_fs_name, snapshot_id):
    fs = _get_fs_by_uuid(req, fs_uuid)

    if not fs:
        raise TargetdError(-104, "fs_uuid not found")

    if snapshot_id:
        snapshot = _get_ss_by_uuid(req, fs_uuid, snapshot_id)
        if not snapshot:
            raise TargetdError(-112, "snapshot not found")

        source = os.path.join(fs['pool'], ss_path, fs['name'], snapshot['name'])
        dest = os.path.join(fs['pool'], fs_path, dest_fs_name)
    else:
        source = os.path.join(fs['pool'], fs_path, fs['name'])
        dest = os.path.join(fs['pool'], fs_path, dest_fs_name)

    if os.path.exists(dest):
        raise TargetdError(-51, "Filesystem with that name exists")

    invoke([fs_cmd, 'subvolume', 'snapshot', source, dest])
Exemple #24
0
def fs_clone(req, fs_uuid, dest_fs_name, snapshot_id):
    fs = _get_fs_by_uuid(req, fs_uuid)

    if not fs:
        raise TargetdError(-104, "fs_uuid not found")

    if snapshot_id:
        snapshot = _get_ss_by_uuid(req, fs_uuid, snapshot_id)
        if not snapshot:
            raise TargetdError(-112, "snapshot not found")

        source = os.path.join(fs['pool'], ss_path, fs['name'], snapshot['name'])
        dest = os.path.join(fs['pool'], fs_path, dest_fs_name)
    else:
        source = os.path.join(fs['pool'], fs_path, fs['name'])
        dest = os.path.join(fs['pool'], fs_path, dest_fs_name)

    if os.path.exists(dest):
        raise TargetdError(-51, "Filesystem with that name exists")

    invoke([fs_cmd, 'subvolume', 'snapshot', source, dest])
Exemple #25
0
def handler(event, context):

    print(json.dumps(event))
    asg = event['asg']['asg']
    stage = os.environ['stage']
    print("Exclude-subnets(%s)" % asg)
    if "prod" in asg and stage != 'prod':
        print("Yikes! Not touching prod...")
        return
    lc_name = event['asg']['lc']
    unavailable_types = event['unavailable_types']
    subnet_to_az = event['subnets']
    region = event['region']

    client = boto3.client("autoscaling", region_name=region)

    used_instance_type = invoke("get-launch-config-instance-type",
                                {
                                    "region": region,
                                    "lc": lc_name,
                                },
                                True)

    if used_instance_type not in unavailable_types:
        return False

    subnets_to_exclude = find_subnets_to_exclude(unavailable_types,
                                                 used_instance_type,
                                                 event['asg'],
                                                 subnet_to_az)

    if not len(subnets_to_exclude):
        print("No subnets to exclude")
        return False

    print("Subnets [%s] should be excluded from ASG %s"
          % (",".join(subnets_to_exclude), asg))

    current_subnets = set(event['asg']['subnets'])
    remaining = current_subnets.difference(set(subnets_to_exclude))
    remaining = ",".join(list(remaining))

    print("Updating ASG %s to include only the following subnets: %s"
          % (asg, remaining))

    record_excluded_subnets_as_tags(subnets_to_exclude, client, asg)

    client.update_auto_scaling_group(
        AutoScalingGroupName=asg,
        VPCZoneIdentifier=remaining
    )
    return True
def save(show_error_message=False):
    """
   Asks for the user to specify a file, and then writes the entire contents of 
   the debug log (since the install() method was called) to the given file.  
   This does not clear the log.
   """

    global __logger, __app_window
    if not __logger or not __app_window:
        return

    def dosave():
        dialog = SaveFileDialog()
        dialog.FileName="cvs-debug-log-" + \
           DateTime.Today.ToString("yyyy-MM-dd") + ".txt"
        dialog.Title = i18n.get("LogSaveTitle")
        dialog.Filter = i18n.get("LogSaveFilter") + '|*.*'

        try:
            if dialog.ShowDialog(__app_window) == DialogResult.OK:
                if dialog.FileName != None:
                    debug("wrote debug logfile: ",
                          FileInfo(dialog.FileName).Name)
                    __logger.save(dialog.FileName)
                    if show_error_message:
                        MessageBox.Show(__app_window, i18n.get("LogSavedText"),
                                        i18n.get("LogSavedTitle"),
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information)
        except:
            debug_exc()
            MessageBox.Show(__app_window, i18n.get("LogSaveFailedText"))

    if __app_window.InvokeRequired:
        # fixes a bug where this doesn't work if you manually invoke from
        # the comciform.
        utils.invoke(__app_window, dosave, False)
    else:
        dosave()
Exemple #27
0
def handler(event, _):
    region = event['region']
    if not region:
        raise Exception('region must be passed in')

    print("Looking for instance types used in region %s" % region)
    used_types = find_lc_instance_types(region)
    print("Instance types used in region %s: %s" %
          (region, ",".join(used_types)))
    azs = list_azs(region)
    print("AZs in region %s: %s" % (region, ",".join(azs)))
    history = get_spot_history(region, used_types)
    print("Spots available in each AZ: %s" % json.dumps(history, indent=1))
    unavailable_types = find_types_missing_in_azs(used_types, azs, history)

    asgs = list_asgs(region)
    for asg in asgs:
        invoke("patch-asg", {
            "asg": asg,
            "region": region,
            "unavailable_types": unavailable_types,
        })
Exemple #28
0
def save(show_error_message=False):
   """
   Asks for the user to specify a file, and then writes the entire contents of 
   the debug log (since the install() method was called) to the given file.  
   This does not clear the log.
   """
   
   global __logger, __app_window
   if not __logger or not __app_window:
      return
   
   def dosave():
      dialog = SaveFileDialog()
      dialog.FileName="cvs-debug-log-" + \
         DateTime.Today.ToString("yyyy-MM-dd") + ".txt"
      dialog.Title = i18n.get("LogSaveTitle")
      dialog.Filter = i18n.get("LogSaveFilter")+'|*.*'
   
      try:
         if dialog.ShowDialog(__app_window) == DialogResult.OK:
            if dialog.FileName != None:
               debug("wrote debug logfile: ", FileInfo(dialog.FileName).Name)
               __logger.save(dialog.FileName)
               if show_error_message:
                  MessageBox.Show(__app_window, i18n.get("LogSavedText"),
                     i18n.get("LogSavedTitle"), MessageBoxButtons.OK, 
                     MessageBoxIcon.Information )
      except:
         debug_exc()
         MessageBox.Show( __app_window, i18n.get("LogSaveFailedText") )
   
   if __app_window.InvokeRequired:
      # fixes a bug where this doesn't work if you manually invoke from
      # the comciform.   
      utils.invoke(__app_window, dosave, False)
   else:
      dosave()
Exemple #29
0
def _invoke_retries(command, throw_exception):
    # TODO take out this loop, used to handle bug in btrfs
    # ERROR: Failed to lookup path for root 0 - No such file or directory

    for i in range(0, 5):
        result, out, err = invoke(command, False)
        if result == 0:
            return result, out, err
        elif result == 19:
            time.sleep(1)
            continue
        else:
            raise TargetdError(-303, "Unexpected exit code %d" % result)

    raise TargetdError(-303, "Unable to execute command after "
                             "multiple retries %s" % (str(command)))
Exemple #30
0
def session_wrapper(session_id=None):
    """
    Returns the iscsiadm command, with session mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "session", "-P", "1"]
    if session_id:
        cmd.extend(["-r", session_id])
    error_code, output_success, output_failure = invoke(cmd, False)
    if error_code != 0:
        error_string = output_failure.splitlines()[0].split(" ", 1)[-1].strip()
        # error_string extracts the text after "iscsiadm: " of the
        # first line of e.output
        error_code = get_error_code(error_code)
        raise TargetdError(error_code, error_string)
    return output_success
Exemple #31
0
def _invoke_retries(command, throw_exception):
    # TODO take out this loop, used to handle bug in btrfs
    # ERROR: Failed to lookup path for root 0 - No such file or directory

    for i in range(0, 5):
        result, out, err = invoke(command, False)
        if result == 0:
            return result, out, err
        elif result == 19:
            time.sleep(1)
            continue
        else:
            raise TargetdError(-303, "Unexpected exit code %d" % result)

    raise TargetdError(-303, "Unable to execute command after "
                             "multiple retries %s" % (str(command)))
def session_wrapper(session_id=None):
    """
    Returns the iscsiadm command, with session mode,
    corresponding to different specified arguments
    """
    cmd = [ISCSIADM_BINARY, "-m", "session", "-P", "1"]
    if session_id:
        cmd.extend(["-r", session_id])
    error_code, output_success, output_failure = invoke(cmd, False)
    if error_code != 0:
        error_string = output_failure.splitlines()[0].split(" ", 1)[-1].strip()
        # error_string extracts the text after "iscsiadm: " of the
        # first line of e.output
        error_code = get_error_code(error_code)
        raise TargetdError(error_code, error_string)
    return output_success
Exemple #33
0
    def export_add(host, path, bit_wise_options, key_value_options):
        """
        Adds a path as an NFS export
        """
        export = Export(host, path, bit_wise_options, key_value_options)
        options = export.options_string()

        cmd = [Nfs.CMD]

        if len(options):
            cmd.extend(['-o', options])

        cmd.extend(['%s:%s' % (host, path)])

        ec, out, err = invoke(cmd, False)
        if ec == 0:
            Nfs._save_exports()
            return None
        elif ec == 22:
            raise ValueError("Invalid option: %s" % err)
        else:
            raise RuntimeError('Unexpected exit code "%s" %s, out= %s' %
                               (str(cmd), str(ec),
                                str(out + ":" + err)))
Exemple #34
0
def create_sub_volume(p):
    if not os.path.exists(p):
        invoke([fs_cmd, 'subvolume', 'create', p])
def setup_module(module):
    utils.invoke('install', 'marathon')
Exemple #36
0
def fs_subvolume_delete(path):
    invoke([fs_cmd, 'subvolume', 'delete', path])
def setup_module(module):
    utils.invoke("install", "hdfs")
def setup_module(module):
    utils.invoke('install', 'zookeeper')
Exemple #39
0
def setup_module(module):
    utils.invoke('install', 'impala')
def setup_module(module):
    utils.invoke('install', 'impala')
def setup_module(module):
    utils.invoke('install', 'spark')
Exemple #42
0
def fs_subvolume_delete(path):
    invoke([fs_cmd, 'subvolume', 'delete', path])
 def get_page():
    page_image[0] = current_book.create_image_of_page(page_index)
    def set_page():
       self.__pbox_panel.set_image(page_image[0]) # image may be None
       self.__pbox_panel.Refresh() # just in case nothing changed
    utils.invoke(self, set_page, False)
def setup_module(module):
    utils.invoke('install', 'notebook')
Exemple #45
0
def create_sub_volume(p):
    if not os.path.exists(p):
        invoke([fs_cmd, 'subvolume', 'create', p])
def setup_module(module):
    utils.invoke('install', 'spark')
def setup_module(module):
    utils.invoke('install', 'notebook')
Exemple #48
0
def setup_module(module):
    utils.invoke('install', 'mesos')
def setup_module(module):
    utils.invoke('install', 'marathon')
Exemple #50
0
def setup_module(module):
    utils.invoke('install', 'zookeeper')
Exemple #51
0
    def export_remove(export):
        ec, out, err = invoke([Nfs.CMD, '-u', '%s:%s' %
                                              (export.host, export.path)])

        if ec == 0:
            Nfs._save_exports()
Exemple #52
0
def setup_module(module):
    result = utils.invoke('install', 'miniconda')
    assert result.exit_code == 0