mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 14:30:30 +03:00 
			
		
		
		
	except named exception handling
This commit is contained in:
		
							parent
							
								
									af38f151a2
								
							
						
					
					
						commit
						5ca182a20d
					
				
					 6 changed files with 10 additions and 10 deletions
				
			
		
							
								
								
									
										2
									
								
								fdroid
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								fdroid
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -137,7 +137,7 @@ def main():
 | 
			
		|||
        sys.exit(1)
 | 
			
		||||
    # These should only be unexpected crashes due to bugs in the code
 | 
			
		||||
    # str(e) often doesn't contain a reason, so just show the backtrace
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        logging.critical("Unknown exception found!")
 | 
			
		||||
        raise
 | 
			
		||||
    sys.exit(0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -280,9 +280,9 @@ def check_gplay(app):
 | 
			
		|||
    try:
 | 
			
		||||
        resp = urllib2.urlopen(req, None, 20)
 | 
			
		||||
        page = resp.read()
 | 
			
		||||
    except urllib2.HTTPError, e:
 | 
			
		||||
    except urllib2.HTTPError as e:
 | 
			
		||||
        return (None, str(e.code))
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        return (None, 'Failed:' + str(e))
 | 
			
		||||
 | 
			
		||||
    version = None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -516,7 +516,7 @@ class vcs:
 | 
			
		|||
 | 
			
		||||
        try:
 | 
			
		||||
            self.gotorevisionx(rev)
 | 
			
		||||
        except FDroidException, e:
 | 
			
		||||
        except FDroidException as e:
 | 
			
		||||
            exc = e
 | 
			
		||||
 | 
			
		||||
        # If necessary, write the .fdroidvcs file.
 | 
			
		||||
| 
						 | 
				
			
			@ -1602,7 +1602,7 @@ def FDroidPopen(commands, cwd=None, output=True):
 | 
			
		|||
    try:
 | 
			
		||||
        p = subprocess.Popen(commands, cwd=cwd, shell=False, env=env,
 | 
			
		||||
                             stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 | 
			
		||||
    except OSError, e:
 | 
			
		||||
    except OSError as e:
 | 
			
		||||
        raise BuildException("OSError while trying to execute " +
 | 
			
		||||
                             ' '.join(commands) + ': ' + str(e))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -800,7 +800,7 @@ def read_metadata(xref=True):
 | 
			
		|||
        for appid, app in apps.iteritems():
 | 
			
		||||
            try:
 | 
			
		||||
                description_html(app.Description, linkres)
 | 
			
		||||
            except MetaDataException, e:
 | 
			
		||||
            except MetaDataException as e:
 | 
			
		||||
                raise MetaDataException("Problem with description of " + appid +
 | 
			
		||||
                                        " - " + str(e))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -331,7 +331,7 @@ def resize_icon(iconpath, density):
 | 
			
		|||
                iconpath, oldsize, im.size))
 | 
			
		||||
            im.save(iconpath, "PNG")
 | 
			
		||||
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        logging.error("Failed resizing {0} - {1}".format(iconpath, e))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -490,7 +490,7 @@ def scan_apks(apps, apkcache, repodir, knownapks):
 | 
			
		|||
                        apk['id'] = re.match(name_pat, line).group(1)
 | 
			
		||||
                        apk['versioncode'] = int(re.match(vercode_pat, line).group(1))
 | 
			
		||||
                        apk['version'] = re.match(vername_pat, line).group(1)
 | 
			
		||||
                    except Exception, e:
 | 
			
		||||
                    except Exception as e:
 | 
			
		||||
                        logging.error("Package matching failed: " + str(e))
 | 
			
		||||
                        logging.info("Line was: " + line)
 | 
			
		||||
                        sys.exit(1)
 | 
			
		||||
| 
						 | 
				
			
			@ -615,7 +615,7 @@ def scan_apks(apps, apkcache, repodir, knownapks):
 | 
			
		|||
                                        os.path.join(get_icon_dir(repodir, density), iconfilename))
 | 
			
		||||
                            empty_densities.remove(density)
 | 
			
		||||
                            break
 | 
			
		||||
                except Exception, e:
 | 
			
		||||
                except Exception as e:
 | 
			
		||||
                    logging.warn("Failed reading {0} - {1}".format(iconpath, e))
 | 
			
		||||
 | 
			
		||||
            if apk['icons']:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ def main():
 | 
			
		|||
            logging.info("...successfully verified")
 | 
			
		||||
            verified += 1
 | 
			
		||||
 | 
			
		||||
        except FDroidException, e:
 | 
			
		||||
        except FDroidException as e:
 | 
			
		||||
            logging.info("...NOT verified - {0}".format(e))
 | 
			
		||||
            notverified += 1
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue