Merge lp:~aj00200/anonplus/setup-bugs into lp:anonplus

Proposed by aj00200
Status: Merged
Approved by: aj00200
Approved revision: 202
Merged at revision: 202
Proposed branch: lp:~aj00200/anonplus/setup-bugs
Merge into: lp:anonplus
Diff against target: 77 lines (+13/-13)
1 file modified
src/setup.py (+13/-13)
To merge this branch: bzr merge lp:~aj00200/anonplus/setup-bugs
Reviewer Review Type Date Requested Status
aj00200 Approve
Review via email: mp+94077@code.launchpad.net

Commit message

Fixed numerous issues with setup.py that would cause more obscure crashes in the event that something did not go right. These bugs were caused by incorrect code in the try blocks.

Description of the change

This change fixed some bugs in setup.py that would only show up if there was an error during the installation. These were all caught by pylint.

To post a comment you must log in.
Revision history for this message
aj00200 (aj00200) wrote :

Everything looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/setup.py'
2--- src/setup.py 2011-12-20 02:18:14 +0000
3+++ src/setup.py 2012-02-22 02:05:20 +0000
4@@ -23,7 +23,7 @@
5 import Crypto
6 import Crypto.PublicKey.RSA
7 except ImportError:
8- raise libs.errors.DependancyError(_('''PyCrypto is required to use Anon+
9+ raise Exception(_('''PyCrypto is required to use Anon+
10 Get it for Linux at https://www.dlitz.net/software/pycrypto/
11 Get it for Windows at http://www.voidspace.org.uk/python/modules.shtml#pycrypto
12 '''))
13@@ -31,7 +31,7 @@
14 # Check PyCrypto version basics - require v2.4.x or higher
15 # The version in PyCrypto is incorrect. See bug #892944
16 if Crypto.version_info[0] < 2 or Crypto.version_info[1] < 1:
17- raise libs.errors.DependancyError(_(
18+ raise Exception(_(
19 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))
20
21 ## Prepare for setup
22@@ -53,7 +53,7 @@
23 print(_(' [*] %s already exists. Do not need to create.' % VOMUN_PATH))
24 else:
25 print(_(' [*] Error creating %s' % VOMUN_PATH))
26- raise libs.errors.InstallError(_(
27+ raise Exception(_(
28 'Please check your file permissions for %s' % HOME))
29
30 ## Key setup
31@@ -70,10 +70,10 @@
32 try:
33 pubkey = keys['nodekey'].publickey().exportKey()
34 except AttributeError:
35- raise libs.errors.DependancyError(_(
36+ raise Exception(_(
37 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))
38 else:
39- keys['nodekey'].hash = hashlib.sha256(pubkey).hexdigest()
40+ keys['nodekey'].hash = hashlib.sha256(pubkey).hexdigest()
41
42 print(_(' [*] Done. Key fingerprint:'))
43 print(' %s' % keys['nodekey'].hash)
44@@ -104,8 +104,8 @@
45 key_file.write(json.dumps(keys_by_hash, indent = 4))
46 key_file.close()
47 except IOError:
48- print(_(' [*] Error writing %s. Check file permissions.' % KEY_PATH))
49- raise libs.errors.InstallError(_('Could not write to %s.' % KEY_PATH))
50+ print(_(' [*] Error writing %s. Check file permissions.' % KEYS_PATH))
51+ raise Exception(_('Could not write to %s.' % KEYS_PATH))
52
53
54 ## Configuration
55@@ -126,16 +126,16 @@
56 config_file.close()
57 except IOError as error:
58 print(_(' [*] Error writing %s. Check file permissions.' % CONFIG_PATH))
59- raise libs.errors.InstallError(_('Could not write to %s.' % CONFIG_PATH))
60+ raise Exception(_('Could not write to %s.' % CONFIG_PATH))
61
62 friendlistpath = os.path.join(VOMUN_PATH, 'friends.json')
63 try:
64- friendlistr = open(friendlistpath, "r")
65- friendlistr.close()
66+ friendlistr = open(friendlistpath, "r")
67+ friendlistr.close()
68 except IOError:
69- friendlistr = open(friendlistpath, "w")
70- friendlistr.write('[]')
71- friendlistr.close()
72+ friendlistr = open(friendlistpath, "w")
73+ friendlistr.write('[]')
74+ friendlistr.close()
75
76 ## Setup complete
77 print(_(' == Setup Complete =='))

Subscribers

People subscribed via source and target branches

to all changes: