From 4afd1fa91d642bc8e4efe42dbe184ea4997b9044 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 5 Jul 2014 19:43:07 +0100 Subject: [PATCH] Remove old sha module import code --- deluge/common.py | 8 +++----- deluge/tests/test_core.py | 6 +----- deluge/ui/common.py | 7 +------ deluge/ui/gtkui/preferences.py | 8 ++------ deluge/ui/gtkui/systemtray.py | 7 ++----- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index b06928f65..01a629c04 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -861,18 +861,16 @@ def create_auth_file(): def create_localclient_account(append=False): import configmanager import random + from hashlib import sha1 as sha + auth_file = configmanager.get_config_dir("auth") if not os.path.exists(auth_file): create_auth_file() - try: - from hashlib import sha1 as sha_hash - except ImportError: - from sha import new as sha_hash fd = open(auth_file, "a" if append else "w") fd.write(":".join([ "localclient", - sha_hash(str(random.random())).hexdigest(), + sha(str(random.random())).hexdigest(), str(AUTH_LEVEL_ADMIN) ]) + '\n') fd.flush() diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index 8692f5ec8..94dd68386 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -1,10 +1,6 @@ import os import warnings - -try: - from hashlib import sha1 as sha -except ImportError: - from sha import sha +from hashlib import sha1 as sha from twisted.trial import unittest from twisted.internet import reactor diff --git a/deluge/ui/common.py b/deluge/ui/common.py index af78d0b59..3e0064027 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -42,13 +42,8 @@ import os import sys import logging import urlparse - import locale - -try: - from hashlib import sha1 as sha -except ImportError: - from sha import sha +from hashlib import sha1 as sha from deluge import bencode from deluge.common import utf8_encoded, path_join diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 7c659afe3..cc43488e9 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -39,6 +39,7 @@ import pygtk pygtk.require('2.0') import gtk import logging +from hashlib import sha1 as sha import deluge.component as component from deluge.ui.client import client @@ -541,11 +542,6 @@ class Preferences(component.Component): :param hide: bool, if True, will not re-show the dialog and will hide it instead """ - try: - from hashlib import sha1 as sha_hash - except ImportError: - from sha import new as sha_hash - classic_mode_was_set = self.gtkui_config["classic_mode"] # Get the values from the dialog @@ -662,7 +658,7 @@ class Preferences(component.Component): self.builder.get_object("chk_enable_appindicator").get_active() new_gtkui_config["lock_tray"] = \ self.builder.get_object("chk_lock_tray").get_active() - passhex = sha_hash(self.builder.get_object("txt_tray_password").get_text()).hexdigest() + passhex = sha(self.builder.get_object("txt_tray_password").get_text()).hexdigest() if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7": new_gtkui_config["tray_password"] = passhex diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 01065e4d6..9b399034c 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -437,10 +437,7 @@ class SystemTray(component.Component): set_value(widget.get_children()[0].get_text().split(" ")[0]) def unlock_tray(self, is_showing_dlg=[False]): - try: - from hashlib import sha1 as sha_hash - except ImportError: - from sha import new as sha_hash + from hashlib import sha1 as sha log.debug("Show tray lock dialog") @@ -488,7 +485,7 @@ class SystemTray(component.Component): def on_response(dialog, response_id): if response_id == gtk.RESPONSE_OK: - if self.config["tray_password"] == sha_hash(entered_pass.get_text()).hexdigest(): + if self.config["tray_password"] == sha(entered_pass.get_text()).hexdigest(): self.window.present() self.tray_lock.destroy()