コード例 #1
0
ファイル: log.py プロジェクト: yckart/ochDownloader
 def load_full_log(self):
     """"""
     try:
         with open(cons.LOG_FILE, "rb") as fh:
             lines = fh.read()
     except EnvironmentError as err:
         lines = str(err)
         #logger.warning("{0}".format(err))
     
     self.text_view.setPlainText(smart_decode(lines))
コード例 #2
0
    def load_full_log(self):
        """"""
        try:
            with open(cons.LOG_FILE, "rb") as fh:
                lines = fh.read()
        except EnvironmentError as err:
            lines = str(err)
            #logger.warning("{0}".format(err))

        self.text_view.setPlainText(smart_decode(lines))
コード例 #3
0
ファイル: log.py プロジェクト: yckart/ochDownloader
 def on_load(self):
     """
     load the last few lines of the file.log
     This method is suppose to be called on switch-tab event (main_gui)
     """
     try:
         with open(cons.LOG_FILE, "rb") as fh:
             last_lines = tail(fh) #misc function
     except EnvironmentError as err:
         last_lines = str(err)
         logger.warning("{0}".format(err))
     
     self.text_view.setPlainText(smart_decode(last_lines))
コード例 #4
0
    def on_load(self):
        """
        load the last few lines of the file.log
        This method is suppose to be called on switch-tab event (main_gui)
        """
        try:
            with open(cons.LOG_FILE, "rb") as fh:
                last_lines = tail(fh)  #misc function
        except EnvironmentError as err:
            last_lines = str(err)
            logger.warning("{0}".format(err))

        self.text_view.setPlainText(smart_decode(last_lines))
コード例 #5
0
ファイル: downloader.py プロジェクト: yckart/ochDownloader
 def __get_filename_from_source(self, info):
     """"""
     file_name = None
     if info.getheader("Content-Disposition", None): #Content-Disposition: Attachment; filename=name.ext
         disposition = info.getheader("Content-Disposition") #get file name
         if 'filename="' in disposition:
             file_name = disposition.split('filename=')[-1].split('"')[1]
         elif "filename='" in disposition:
             file_name = disposition.split('filename=')[-1].split("'")[1]
         elif 'filename=' in disposition:
             file_name = disposition.split('filename=')[-1]
         elif 'filename*=' in disposition:
             file_name = disposition.split("'")[-1]
     if not file_name: #may be an empty string or None
         file_name = misc.get_filename_from_url(self.source.url)
     file_name = misc.html_entities_parser(file_name)
     file_name = urllib.unquote_plus(file_name)
     file_name = misc.smart_decode(file_name)
     file_name = misc.strip(file_name, to_strip='/\\:*?"<>|')
     file_name = file_name.strip('.')
     return file_name
コード例 #6
0
ファイル: downloader.py プロジェクト: yckart/ochDownloader
 def __get_filename_from_source(self, info):
     """"""
     file_name = None
     if info.getheader(
             "Content-Disposition",
             None):  #Content-Disposition: Attachment; filename=name.ext
         disposition = info.getheader("Content-Disposition")  #get file name
         if 'filename="' in disposition:
             file_name = disposition.split('filename=')[-1].split('"')[1]
         elif "filename='" in disposition:
             file_name = disposition.split('filename=')[-1].split("'")[1]
         elif 'filename=' in disposition:
             file_name = disposition.split('filename=')[-1]
         elif 'filename*=' in disposition:
             file_name = disposition.split("'")[-1]
     if not file_name:  #may be an empty string or None
         file_name = misc.get_filename_from_url(self.source.url)
     file_name = misc.html_entities_parser(file_name)
     file_name = urllib.unquote_plus(file_name)
     file_name = misc.smart_decode(file_name)
     file_name = misc.strip(file_name, to_strip='/\\:*?"<>|')
     file_name = file_name.strip('.')
     return file_name