Remove old sha module import code

This commit is contained in:
Calum Lind 2014-07-05 19:43:07 +01:00
parent c5722011e8
commit 4afd1fa91d
5 changed files with 9 additions and 27 deletions

View File

@ -861,18 +861,16 @@ def create_auth_file():
def create_localclient_account(append=False): def create_localclient_account(append=False):
import configmanager import configmanager
import random import random
from hashlib import sha1 as sha
auth_file = configmanager.get_config_dir("auth") auth_file = configmanager.get_config_dir("auth")
if not os.path.exists(auth_file): if not os.path.exists(auth_file):
create_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 = open(auth_file, "a" if append else "w")
fd.write(":".join([ fd.write(":".join([
"localclient", "localclient",
sha_hash(str(random.random())).hexdigest(), sha(str(random.random())).hexdigest(),
str(AUTH_LEVEL_ADMIN) str(AUTH_LEVEL_ADMIN)
]) + '\n') ]) + '\n')
fd.flush() fd.flush()

View File

@ -1,10 +1,6 @@
import os import os
import warnings import warnings
from hashlib import sha1 as sha
try:
from hashlib import sha1 as sha
except ImportError:
from sha import sha
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import reactor from twisted.internet import reactor

View File

@ -42,13 +42,8 @@ import os
import sys import sys
import logging import logging
import urlparse import urlparse
import locale import locale
from hashlib import sha1 as sha
try:
from hashlib import sha1 as sha
except ImportError:
from sha import sha
from deluge import bencode from deluge import bencode
from deluge.common import utf8_encoded, path_join from deluge.common import utf8_encoded, path_join

View File

@ -39,6 +39,7 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import logging import logging
from hashlib import sha1 as sha
import deluge.component as component import deluge.component as component
from deluge.ui.client import client 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 :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"] classic_mode_was_set = self.gtkui_config["classic_mode"]
# Get the values from the dialog # Get the values from the dialog
@ -662,7 +658,7 @@ class Preferences(component.Component):
self.builder.get_object("chk_enable_appindicator").get_active() self.builder.get_object("chk_enable_appindicator").get_active()
new_gtkui_config["lock_tray"] = \ new_gtkui_config["lock_tray"] = \
self.builder.get_object("chk_lock_tray").get_active() 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": if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7":
new_gtkui_config["tray_password"] = passhex new_gtkui_config["tray_password"] = passhex

View File

@ -437,10 +437,7 @@ class SystemTray(component.Component):
set_value(widget.get_children()[0].get_text().split(" ")[0]) set_value(widget.get_children()[0].get_text().split(" ")[0])
def unlock_tray(self, is_showing_dlg=[False]): def unlock_tray(self, is_showing_dlg=[False]):
try: from hashlib import sha1 as sha
from hashlib import sha1 as sha_hash
except ImportError:
from sha import new as sha_hash
log.debug("Show tray lock dialog") log.debug("Show tray lock dialog")
@ -488,7 +485,7 @@ class SystemTray(component.Component):
def on_response(dialog, response_id): def on_response(dialog, response_id):
if response_id == gtk.RESPONSE_OK: 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.window.present()
self.tray_lock.destroy() self.tray_lock.destroy()