diff --git a/plugins/CryptMessage/CryptMessagePlugin.py b/plugins/CryptMessage/CryptMessagePlugin.py index 0302c83a..71499eca 100644 --- a/plugins/CryptMessage/CryptMessagePlugin.py +++ b/plugins/CryptMessage/CryptMessagePlugin.py @@ -53,7 +53,7 @@ class UiWebsocketPlugin(object): try: text = self.decrypt(encrypted_text.decode("base64"), privatekey) texts.append(text) - except Exception, err: + except Exception as err: texts.append(None) if type(param) == list: diff --git a/plugins/FilePack/FilePackPlugin.py b/plugins/FilePack/FilePackPlugin.py index 7ba6b452..08725960 100644 --- a/plugins/FilePack/FilePackPlugin.py +++ b/plugins/FilePack/FilePackPlugin.py @@ -59,7 +59,7 @@ class UiRequestPlugin(object): content_type = self.getContentType(file_path) self.sendHeader(200, content_type=content_type, noscript=kwargs.get("header_noscript", False)) return self.streamFile(file) - except Exception, err: + except Exception as err: self.log.debug("Error opening archive file: %s" % err) return self.error404(path) diff --git a/plugins/Mute/MutePlugin.py b/plugins/Mute/MutePlugin.py index e1d6fb05..e30a6c38 100644 --- a/plugins/Mute/MutePlugin.py +++ b/plugins/Mute/MutePlugin.py @@ -14,7 +14,7 @@ if os.path.isfile("%s/mutes.json" % config.data_dir): data = json.load(open("%s/mutes.json" % config.data_dir)) mutes = data.get("mutes", {}) site_blacklist = data.get("site_blacklist", {}) - except Exception, err: + except Exception as err: mutes = {} site_blacklist = {} else: diff --git a/plugins/Newsfeed/NewsfeedPlugin.py b/plugins/Newsfeed/NewsfeedPlugin.py index feaf8542..949e62b6 100644 --- a/plugins/Newsfeed/NewsfeedPlugin.py +++ b/plugins/Newsfeed/NewsfeedPlugin.py @@ -60,7 +60,7 @@ class UiWebsocketPlugin(object): else: res = site.storage.query(query + " ORDER BY date_added DESC LIMIT %s" % limit) - except Exception, err: # Log error + except Exception as err: # Log error self.log.error("%s feed query %s error: %s" % (address, name, err)) continue diff --git a/plugins/OptionalManager/ContentDbPlugin.py b/plugins/OptionalManager/ContentDbPlugin.py index 9df52f00..d1a1dd29 100644 --- a/plugins/OptionalManager/ContentDbPlugin.py +++ b/plugins/OptionalManager/ContentDbPlugin.py @@ -132,7 +132,7 @@ class ContentDbPlugin(object): content = site.content_manager.contents[row["inner_path"]] try: num += self.setContentFilesOptional(site, row["inner_path"], content, cur=cur) - except Exception, err: + except Exception as err: self.log.error("Error loading %s into file_optional: %s" % (row["inner_path"], err)) cur.execute("COMMIT") cur.close() @@ -159,7 +159,7 @@ class ContentDbPlugin(object): cur = self try: cur.execute("BEGIN") - except Exception, err: + except Exception as err: self.log.warning("Transaction begin error %s %s: %s" % (site, content_inner_path, Debug.formatException(err))) num = 0 @@ -195,7 +195,7 @@ class ContentDbPlugin(object): if cur == self: try: cur.execute("END") - except Exception, err: + except Exception as err: self.log.warning("Transaction end error %s %s: %s" % (site, content_inner_path, Debug.formatException(err))) return num @@ -387,7 +387,7 @@ class ContentDbPlugin(object): site.content_manager.optionalRemove(row["inner_path"], row["hash_id"], row["size"]) site.storage.delete(row["inner_path"]) need_delete -= row["size"] - except Exception, err: + except Exception as err: site.log.error("Error deleting %s: %s" % (row["inner_path"], err)) if need_delete <= 0: diff --git a/plugins/OptionalManager/UiWebsocketPlugin.py b/plugins/OptionalManager/UiWebsocketPlugin.py index 91f7f6f8..b34b5b88 100644 --- a/plugins/OptionalManager/UiWebsocketPlugin.py +++ b/plugins/OptionalManager/UiWebsocketPlugin.py @@ -137,7 +137,7 @@ class UiWebsocketPlugin(object): try: site.storage.delete(inner_path) - except Exception, err: + except Exception as err: return self.response(to, {"error": "File delete error: %s" % err}) self.response(to, "ok") diff --git a/plugins/PeerDb/PeerDbPlugin.py b/plugins/PeerDb/PeerDbPlugin.py index 72e585ee..5e968b8b 100644 --- a/plugins/PeerDb/PeerDbPlugin.py +++ b/plugins/PeerDb/PeerDbPlugin.py @@ -79,7 +79,7 @@ class ContentDbPlugin(object): "INSERT INTO peer (site_id, address, port, hashfield, time_added) VALUES (?, ?, ?, ?, ?)", self.iteratePeers(site) ) - except Exception, err: + except Exception as err: site.log.error("Save peer error: %s" % err) finally: cur.execute("END") diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index 41cbadc0..99339fd0 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -171,7 +171,7 @@ class UiWebsocketPlugin(object): size_total = size_other = site.settings["size"] # Bar - for extension, color in extensions: + for extension as color in extensions: if extension == "Total": continue if extension == "Other": @@ -502,7 +502,7 @@ class UiWebsocketPlugin(object): self.cmd("notification", ["geolite-done", _["GeoLite2 City database downloaded!"], 5000]) time.sleep(2) # Wait for notify animation return True - except Exception, err: + except Exception as err: self.log.error("Error downloading %s: %s" % (db_url, err)) pass self.cmd("notification", [ diff --git a/plugins/disabled-Dnschain/SiteManagerPlugin.py b/plugins/disabled-Dnschain/SiteManagerPlugin.py index 9121b425..1a41a9d7 100644 --- a/plugins/disabled-Dnschain/SiteManagerPlugin.py +++ b/plugins/disabled-Dnschain/SiteManagerPlugin.py @@ -60,7 +60,7 @@ class SiteManagerPlugin(object): return data["zeronet"].get(sub_domain) # Not found return address - except Exception, err: + except Exception as err: log.debug("Dnschain.net %s resolve error: %s" % (domain, Debug.formatException(err))) @@ -82,7 +82,7 @@ class SiteManagerPlugin(object): return data["zeronet"].get(sub_domain) # Not found return address - except Exception, err: + except Exception as err: log.debug("Dnschain.info %s resolve error: %s" % (domain, Debug.formatException(err))) diff --git a/plugins/disabled-StemPort/__init__.py b/plugins/disabled-StemPort/__init__.py index 1ce4d973..71150ad6 100644 --- a/plugins/disabled-StemPort/__init__.py +++ b/plugins/disabled-StemPort/__init__.py @@ -1,7 +1,7 @@ try: from stem.control import Controller stem_found = True -except Exception, err: +except Exception as err: print "STEM NOT FOUND! %s" % err stem_found = False diff --git a/src/main.py b/src/main.py index d9426a28..e74bc71c 100644 --- a/src/main.py +++ b/src/main.py @@ -32,14 +32,14 @@ if not os.path.isdir(config.log_dir): os.mkdir(config.log_dir) try: os.chmod(config.log_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - except Exception, err: + except Exception as err: print "Can't change permission of %s: %s" % (config.log_dir, err) if not os.path.isdir(config.data_dir): os.mkdir(config.data_dir) try: os.chmod(config.data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - except Exception, err: + except Exception as err: print "Can't change permission of %s: %s" % (config.data_dir, err) if not os.path.isfile("%s/sites.json" % config.data_dir):