Python exceptions.IOError() Examples
The following are 8
code examples of exceptions.IOError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
exceptions
, or try the search function
.
Example #1
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 5 votes |
def _scrap_thumb_launcher_algo(self, launcherID, title): xbmc_notify(__language__( 30000 ), __language__( 30065 ) % (self.launchers[launcherID]["name"],(self.settings[ "thumbs_scraper" ]).encode('utf-8','ignore')),30000) covers = self._get_thumbnails_list(self.launchers[launcherID]["gamesys"],title,self.settings["game_region"],self.settings[ "thumb_image_size" ]) if covers: nb_images = len(covers) xbmc_notify(__language__( 30000 ), __language__( 30066 ) % (nb_images,self.launchers[launcherID]["name"]),3000) covers.insert(0,(self.launchers[launcherID]["thumb"],self.launchers[launcherID]["thumb"],__language__( 30068 ))) self.image_url = MyDialog(covers) if ( self.image_url ): if (not self.image_url == self.launchers[launcherID]["thumb"]): img_url = self._get_thumbnail(self.image_url) if ( img_url != '' ): img_ext = os.path.splitext(img_url)[-1][0:4] if ( img_ext != '' ): filename = self.launchers[launcherID]["application"] if ( os.path.join(self.launchers[launcherID]["thumbpath"]) != "" ): file_path = os.path.join(self.launchers[launcherID]["thumbpath"],os.path.basename(self.launchers[launcherID]["application"])+'_thumb'+img_ext) else: if (self.settings[ "launcher_thumb_path" ] == "" ): self.settings[ "launcher_thumb_path" ] = DEFAULT_THUMB_PATH file_path = os.path.join(self.settings[ "launcher_thumb_path" ],os.path.basename(self.launchers[launcherID]["application"])+'_thumb'+img_ext) xbmc_notify(__language__( 30000 ), __language__( 30069 ),300000) try: download_img(img_url,file_path) if ( self.launchers[launcherID]["thumb"] != "" ): _update_cache(file_path) self.launchers[launcherID]["thumb"] = file_path self._save_launchers() xbmc_notify(__language__( 30000 ), __language__( 30070 ),3000) except socket.timeout: xbmc_notify(__language__( 30000 ), __language__( 30081 ),3000) except exceptions.IOError: xbmc_notify(__language__( 30000 ), __language__( 30063 ) % self.launchers[launcherID]["name"],3000) else: xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.launchers[launcherID]["name"]),3000) else: xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.launchers[launcherID]["name"]),3000)
Example #2
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 5 votes |
def _scrap_thumb_category_algo(self, categoryID, title): xbmc_notify(__language__( 30000 ), __language__( 30065 ) % (self.categories[categoryID]["name"],(self.settings[ "thumbs_scraper" ]).encode('utf-8','ignore')),300000) covers = self._get_thumbnails_list("",title,"",self.settings[ "thumb_image_size" ]) if covers: nb_images = len(covers) xbmc_notify(__language__( 30000 ), __language__( 30066 ) % (nb_images,self.categories[categoryID]["name"]),3000) covers.insert(0,(self.categories[categoryID]["thumb"],self.categories[categoryID]["thumb"],__language__( 30068 ))) self.image_url = MyDialog(covers) if ( self.image_url ): if (not self.image_url == self.categories[categoryID]["thumb"]): img_url = self._get_thumbnail(self.image_url) if ( img_url != '' ): img_ext = os.path.splitext(img_url)[-1][0:4] if ( img_ext != '' ): filename = self.categories[categoryID]["name"] file_path = os.path.join(DEFAULT_THUMB_PATH,os.path.basename(self.categories[categoryID]["name"])+'_thumb'+img_ext) xbmc_notify(__language__( 30000 ), __language__( 30069 ),300000) try: download_img(img_url,file_path) if ( self.categories[categoryID]["thumb"] != "" ): _update_cache(file_path) self.categories[categoryID]["thumb"] = file_path self._save_launchers() xbmc_notify(__language__( 30000 ), __language__( 30070 ),3000) except socket.timeout: xbmc_notify(__language__( 30000 ), __language__( 30081 ),3000) except exceptions.IOError: xbmc_notify(__language__( 30000 ), __language__( 30063 ) % self.categories[categoryID]["name"],3000) else: xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.categories[categoryID]["name"]),3000) else: xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.categories[categoryID]["name"]),3000)
Example #3
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 5 votes |
def _scrap_fanart_rom_algo(self, launcher, rom, title): xbmc_notify(__language__( 30000 ), __language__( 30071 ) % (self.launchers[launcher]["roms"][rom]["name"],self.settings[ "fanarts_scraper" ].encode('utf-8','ignore')),300000) full_fanarts = self._get_fanarts_list(self.launchers[launcher]["roms"][rom]["gamesys"],title,self.settings[ "fanart_image_size" ]) if full_fanarts: nb_images = len(full_fanarts) xbmc_notify(__language__( 30000 ), __language__( 30072 ) % (nb_images,self.launchers[launcher]["roms"][rom]["name"]),3000) full_fanarts.insert(0,(self.launchers[launcher]["roms"][rom]["fanart"],self.launchers[launcher]["roms"][rom]["fanart"],__language__( 30068 ))) self.image_url = MyDialog(full_fanarts) if ( self.image_url ): if (not self.image_url == self.launchers[launcher]["roms"][rom]["fanart"]): img_url = self._get_fanart(self.image_url) if ( img_url != '' ): img_ext = os.path.splitext(img_url)[-1][0:4] if ( img_ext != '' ): filename = self.launchers[launcher]["roms"][rom]["filename"] if (self.launchers[launcher]["fanartpath"] == self.launchers[launcher]["thumbpath"] ): if (self.launchers[launcher]["fanartpath"] == self.launchers[launcher]["rompath"] ): file_path = filename.replace("."+filename.split(".")[-1], '_fanart'+img_ext) else: file_path = os.path.join(os.path.dirname(self.launchers[launcher]["fanartpath"]),os.path.basename(filename.replace("."+filename.split(".")[-1], '_fanart'+img_ext))) else: if (self.launchers[launcher]["fanartpath"] == self.launchers[launcher]["rompath"] ): file_path = filename.replace("."+filename.split(".")[-1], img_ext) else: file_path = os.path.join(os.path.dirname(self.launchers[launcher]["fanartpath"]),os.path.basename(filename.replace("."+filename.split(".")[-1], img_ext))) xbmc_notify(__language__( 30000 ), __language__( 30074 ),300000) try: download_img(img_url,file_path) if ( self.launchers[launcher]["roms"][rom]["fanart"] != "" ): _update_cache(file_path) self.launchers[launcher]["roms"][rom]["fanart"] = file_path self._save_launchers() xbmc_notify(__language__( 30000 ), __language__( 30075 ),3000) except socket.timeout: xbmc_notify(__language__( 30000 ), __language__( 30081 ),3000) except exceptions.IOError: xbmc_notify(__language__( 30000 ), __language__( 30064 ) % self.launchers[launcher]["roms"][rom]["name"],3000) else: xbmc_notify(__language__( 30000 ), __language__( 30073 ) % (self.launchers[launcher]["roms"][rom]["name"]),3000) else: xbmc_notify(__language__( 30000 ), __language__( 30073 ) % (self.launchers[launcher]["roms"][rom]["name"]),3000)
Example #4
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 5 votes |
def _scrap_fanart_category_algo(self, categoryID, title): xbmc_notify(__language__( 30000 ), __language__( 30071 ) % (self.categories[categoryID]["name"],(self.settings[ "fanarts_scraper" ]).encode('utf-8','ignore')),300000) covers = self._get_fanarts_list("",title,self.settings[ "fanart_image_size" ]) if covers: nb_images = len(covers) xbmc_notify(__language__( 30000 ), __language__( 30072 ) % (nb_images,self.categories[categoryID]["name"]),3000) covers.insert(0,(self.categories[categoryID]["fanart"],self.categories[categoryID]["fanart"],__language__( 30068 ))) self.image_url = MyDialog(covers) if ( self.image_url ): if (not self.image_url == self.categories[categoryID]["fanart"]): img_url = self._get_fanart(self.image_url) if ( img_url != '' ): img_ext = os.path.splitext(img_url)[-1][0:4] if ( img_ext != '' ): filename = self.categories[categoryID]["name"] file_path = os.path.join(DEFAULT_FANART_PATH,os.path.basename(self.categories[categoryID]["name"])+'_fanart'+img_ext) xbmc_notify(__language__( 30000 ), __language__( 30074 ),300000) try: download_img(img_url,file_path) if ( self.categories[categoryID]["fanart"] != "" ): _update_cache(file_path) self.categories[categoryID]["fanart"] = file_path self._save_launchers() xbmc_notify(__language__( 30000 ), __language__( 30075 ),3000) except socket.timeout: xbmc_notify(__language__( 30000 ), __language__( 30081 ),3000) except exceptions.IOError: xbmc_notify(__language__( 30000 ), __language__( 30064 ) % self.categories[categoryID]["name"],3000) else: xbmc_notify(__language__( 30000 ), __language__( 30073 ) % (self.categories[categoryID]["name"]),3000) else: xbmc_notify(__language__( 30000 ), __language__( 30073 ) % (self.categories[categoryID]["name"]),3000)
Example #5
Source File: utils.py From tensor with MIT License | 5 votes |
def _acquire_cache(self): try: cache_file = open(self.location, 'r') except IOError: return {} cache = json.loads(cache_file.read()) cache_file.close() return cache
Example #6
Source File: S3UploadThread.py From mongodb_consistent_backup with Apache License 2.0 | 4 votes |
def run(self): try: tries = 0 exception = None while tries < self.retries: if self.do_stop: break try: if self.multipart_id and self.multipart_num and self.multipart_parts: mp_log_info = "s3://%s%s (multipart: %d/%d, size: %.2fmb)" % ( self.bucket_name, self.short_key_name(self.key_name), self.multipart_num, self.multipart_parts, float(self.byte_count / 1024.00 / 1024.00)) for mp in self.bucket.get_all_multipart_uploads(): if mp.id == self.multipart_id: logging.info("Uploading AWS S3 key: %s" % mp_log_info) callback_count = 10 if self.target_bandwidth is not None: # request a callback every 0.5MB to allow for somewhat decent throttling callback_count = self.byte_count / 1024 / 1024 / 0.5 with FileChunkIO(self.file_name, 'r', offset=self.multipart_offset, bytes=self.byte_count) as fp: mp.upload_part_from_file(fp=fp, cb=self.status, num_cb=callback_count, part_num=self.multipart_num) break else: raise OperationError("Missing multipart upload id %s for %s in S3 response." % (self.multipart_id, mp_log_info)) else: key = None try: logging.info("Uploading AWS S3 key: %s (multipart: None, size: %.2fmb)" % ( self.short_key_name(self.key_name), float(self.byte_count / 1024.00 / 1024.00) )) key = Key(bucket=self.bucket, name=self.key_name) callback_count = 10 if self.target_bandwidth is not None: # request a callback every 0.5MB to allow for somewhat decent throttling callback_count = self.byte_count / 1024.00 / 1024.00 / 0.5 key.set_contents_from_filename(self.file_name, cb=self.status, num_cb=callback_count) finally: if key: key.close() break except (httplib.HTTPException, exceptions.IOError, socket.error, socket.gaierror) as e: logging.error("Got exception during upload: '%s', retrying upload" % e) exception = e finally: sleep(self.retry_sleep_secs) tries += 1 if tries >= self.retries and exception: raise exception except Exception as e: logging.fatal("AWS S3 upload failed after %i retries! Error: %s" % (self.retries, e)) raise e return self.file_name, self.key_name, self.multipart_num
Example #7
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 4 votes |
def _scrap_thumb_rom_algo(self, launcher, rom, title): xbmc_notify(__language__( 30000 ), __language__( 30065 ) % (self.launchers[launcher]["roms"][rom]["name"],(self.settings[ "thumbs_scraper" ]).encode('utf-8','ignore')),300000) xbmc.executebuiltin( "ActivateWindow(busydialog)" ) covers = self._get_thumbnails_list(self.launchers[launcher]["roms"][rom]["gamesys"],title,self.settings["game_region"],self.settings[ "thumb_image_size" ]) if covers: nb_images = len(covers) xbmc.executebuiltin( "Dialog.Close(busydialog)" ) xbmc_notify(__language__( 30000 ), __language__( 30066 ) % (nb_images,self.launchers[launcher]["roms"][rom]["name"]),3000) covers.insert(0,(self.launchers[launcher]["roms"][rom]["thumb"],self.launchers[launcher]["roms"][rom]["thumb"],__language__( 30068 ))) self.image_url = MyDialog(covers) if ( self.image_url ): if (not self.image_url == self.launchers[launcher]["roms"][rom]["thumb"]): img_url = self._get_thumbnail(self.image_url) if ( img_url != '' ): img_ext = os.path.splitext(img_url)[-1][0:4] if ( img_ext != '' ): filename = self.launchers[launcher]["roms"][rom]["filename"] if (self.launchers[launcher]["thumbpath"] == self.launchers[launcher]["fanartpath"] ): if (self.launchers[launcher]["thumbpath"] == self.launchers[launcher]["rompath"] ): file_path = filename.replace("."+filename.split(".")[-1], '_thumb'+img_ext) else: file_path = os.path.join(os.path.dirname(self.launchers[launcher]["thumbpath"]),os.path.basename(filename.replace("."+filename.split(".")[-1], '_thumb'+img_ext))) else: if (self.launchers[launcher]["thumbpath"] == self.launchers[launcher]["rompath"] ): file_path = filename.replace("."+filename.split(".")[-1], img_ext) else: file_path = os.path.join(os.path.dirname(self.launchers[launcher]["thumbpath"]),os.path.basename(filename.replace("."+filename.split(".")[-1], img_ext))) xbmc_notify(__language__( 30000 ), __language__( 30069 ),300000) try: download_img(img_url,file_path) req = urllib2.Request(img_url) req.add_unredirected_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31') f = open(file_path,'wb') f.write(urllib2.urlopen(req).read()) f.close() if ( self.launchers[launcher]["roms"][rom]["thumb"] != "" ): _update_cache(file_path) self.launchers[launcher]["roms"][rom]["thumb"] = file_path self._save_launchers() xbmc_notify(__language__( 30000 ), __language__( 30070 ),3000) except socket.timeout: xbmc_notify(__language__( 30000 ), __language__( 30081 ),3000) except exceptions.IOError: xbmc_notify(__language__( 30000 ), __language__( 30063 ) % self.launchers[launcher]["roms"][rom]["name"],3000) else: xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.launchers[launcher]["roms"][rom]["name"]),3000) else: xbmc.executebuiltin( "Dialog.Close(busydialog)" ) xbmc_notify(__language__( 30000 ), __language__( 30067 ) % (self.launchers[launcher]["roms"][rom]["name"]),3000)
Example #8
Source File: launcher_plugin.py From advanced-launcher with GNU General Public License v2.0 | 4 votes |
def _save_launchers (self): self._print_log(__language__( 30746 )) xbmc.executebuiltin( "ActivateWindow(busydialog)" ) if ( self.settings[ "auto_backup" ] ): # Delete oldest backup file fileData = {} dirList=os.listdir(DEFAULT_BACKUP_PATH) for fname in dirList: fileData[fname] = os.stat(os.path.join( DEFAULT_BACKUP_PATH,fname)).st_mtime sortedFiles = sorted(fileData.items(), key=itemgetter(1)) delete = len(sortedFiles) - self.settings[ "nb_backup_files" ] + 1 for x in range(0, delete): os.remove(os.path.join( DEFAULT_BACKUP_PATH,sortedFiles[x][0])) # Make a backup of current launchers.xml file if ( os.path.isfile(BASE_CURRENT_SOURCE_PATH)): try: now = datetime.datetime.now() timestamp = str(now.year)+str(now.month).rjust(2,'0')+str(now.day).rjust(2,'0')+"-"+str(now.hour).rjust(2,'0')+str(now.minute).rjust(2,'0')+str(now.second).rjust(2,'0')+"-"+str(now.microsecond)+"-" BACKUP_CURRENT_SOURCE_PATH = os.path.join( DEFAULT_BACKUP_PATH , timestamp+"launchers.xml" ) shutil.copy2(BASE_CURRENT_SOURCE_PATH, BACKUP_CURRENT_SOURCE_PATH) except OSError: xbmc_notify(__language__( 30000 )+" - "+__language__( 30612 ), __language__( 30600 ),3000) try: xml_content = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<advanced_launcher version=\"1.0\">\n\t<categories>\n" # Create Categories XML list for categoryIndex in sorted(self.categories, key= lambda x : self.categories[x]["name"]): category = self.categories[categoryIndex] xml_content += "\t\t<category>\n\t\t\t<id>"+categoryIndex+"</id>\n\t\t\t<name>"+category["name"]+"</name>\n\t\t\t<thumb>"+category["thumb"]+"</thumb>\n\t\t\t<fanart>"+category["fanart"]+"</fanart>\n\t\t\t<genre>"+category["genre"]+"</genre>\n\t\t\t<description>"+category["plot"]+"</description>\n\t\t\t<finished>"+category["finished"]+"</finished>\n\t\t</category>\n" xml_content += "\t</categories>\n\t<launchers>\n" # Create Launchers XML list for launcherIndex in sorted(self.launchers, key= lambda x : self.launchers[x]["name"]): launcher = self.launchers[launcherIndex] xml_content += "\t\t<launcher>\n\t\t\t<id>"+launcherIndex+"</id>\n\t\t\t<name>"+launcher["name"]+"</name>\n\t\t\t<category>"+launcher["category"]+"</category>\n\t\t\t<application>"+launcher["application"]+"</application>\n\t\t\t<args>"+launcher["args"]+"</args>\n\t\t\t<rompath>"+launcher["rompath"]+"</rompath>\n\t\t\t<thumbpath>"+launcher["thumbpath"]+"</thumbpath>\n\t\t\t<fanartpath>"+launcher["fanartpath"]+"</fanartpath>\n\t\t\t<trailerpath>"+launcher["trailerpath"]+"</trailerpath>\n\t\t\t<custompath>"+launcher["custompath"]+"</custompath>\n\t\t\t<romext>"+launcher["romext"]+"</romext>\n\t\t\t<platform>"+launcher["gamesys"]+"</platform>\n\t\t\t<thumb>"+launcher["thumb"]+"</thumb>\n\t\t\t<fanart>"+launcher["fanart"]+"</fanart>\n\t\t\t<genre>"+launcher["genre"]+"</genre>\n\t\t\t<release>"+launcher["release"]+"</release>\n\t\t\t<publisher>"+launcher["studio"]+"</publisher>\n\t\t\t<launcherplot>"+launcher["plot"]+"</launcherplot>\n\t\t\t<finished>"+launcher["finished"]+"</finished>\n\t\t\t<minimize>"+launcher["minimize"]+"</minimize>\n\t\t\t<lnk>"+launcher["lnk"]+"</lnk>\n\t\t\t<roms>\n" # Create Items XML list for romIndex in sorted(launcher["roms"], key= lambda x : launcher["roms"][x]["name"]): romdata = launcher["roms"][romIndex] xml_content += "\t\t\t\t<rom>\n\t\t\t\t\t<id>"+romIndex+"</id>\n\t\t\t\t\t<name>"+romdata["name"]+"</name>\n\t\t\t\t\t<filename>"+romdata["filename"]+"</filename>\n\t\t\t\t\t<thumb>"+romdata["thumb"]+"</thumb>\n\t\t\t\t\t<fanart>"+romdata["fanart"]+"</fanart>\n\t\t\t\t\t<trailer>"+romdata["trailer"]+"</trailer>\n\t\t\t\t\t<custom>"+romdata["custom"]+"</custom>\n\t\t\t\t\t<genre>"+romdata["genre"]+"</genre>\n\t\t\t\t\t<release>"+romdata["release"]+"</release>\n\t\t\t\t\t<publisher>"+romdata["studio"]+"</publisher>\n\t\t\t\t\t<gameplot>"+romdata["plot"]+"</gameplot>\n\t\t\t\t\t<finished>"+romdata["finished"]+"</finished>\n\t\t\t\t\t<altapp>"+romdata["altapp"]+"</altapp>\n\t\t\t\t\t<altarg>"+romdata["altarg"]+"</altarg>\n\t\t\t\t</rom>\n" xml_content += "\t\t\t</roms>\n\t\t</launcher>\n" xml_content += "\t</launchers>\n</advanced_launcher>" # Save launchers.tmp file usock = open( TEMP_CURRENT_SOURCE_PATH, 'w' ) usock.write(xml_content) usock.close() try: shutil.copy2(TEMP_CURRENT_SOURCE_PATH, BASE_CURRENT_SOURCE_PATH) except OSError: xbmc_notify(__language__( 30000 )+" - "+__language__( 30612 ), __language__( 30601 ),3000) except OSError: xbmc_notify(__language__( 30000 )+" - "+__language__( 30612 ), __language__( 30602 ),3000) except IOError: xbmc_notify(__language__( 30000 )+" - "+__language__( 30612 ), __language__( 30603 ),3000) os.remove(TEMP_CURRENT_SOURCE_PATH) xbmc.executebuiltin( "Dialog.Close(busydialog)" )