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
=== modified file 'src/setup.py'
--- src/setup.py 2011-12-20 02:18:14 +0000
+++ src/setup.py 2012-02-22 02:05:20 +0000
@@ -23,7 +23,7 @@
23 import Crypto23 import Crypto
24 import Crypto.PublicKey.RSA24 import Crypto.PublicKey.RSA
25except ImportError:25except ImportError:
26 raise libs.errors.DependancyError(_('''PyCrypto is required to use Anon+26 raise Exception(_('''PyCrypto is required to use Anon+
27 Get it for Linux at https://www.dlitz.net/software/pycrypto/27 Get it for Linux at https://www.dlitz.net/software/pycrypto/
28 Get it for Windows at http://www.voidspace.org.uk/python/modules.shtml#pycrypto28 Get it for Windows at http://www.voidspace.org.uk/python/modules.shtml#pycrypto
29 '''))29 '''))
@@ -31,7 +31,7 @@
31# Check PyCrypto version basics - require v2.4.x or higher31# Check PyCrypto version basics - require v2.4.x or higher
32# The version in PyCrypto is incorrect. See bug #89294432# The version in PyCrypto is incorrect. See bug #892944
33if Crypto.version_info[0] < 2 or Crypto.version_info[1] < 1:33if Crypto.version_info[0] < 2 or Crypto.version_info[1] < 1:
34 raise libs.errors.DependancyError(_(34 raise Exception(_(
35 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))35 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))
3636
37## Prepare for setup37## Prepare for setup
@@ -53,7 +53,7 @@
53 print(_(' [*] %s already exists. Do not need to create.' % VOMUN_PATH))53 print(_(' [*] %s already exists. Do not need to create.' % VOMUN_PATH))
54 else:54 else:
55 print(_(' [*] Error creating %s' % VOMUN_PATH))55 print(_(' [*] Error creating %s' % VOMUN_PATH))
56 raise libs.errors.InstallError(_(56 raise Exception(_(
57 'Please check your file permissions for %s' % HOME))57 'Please check your file permissions for %s' % HOME))
5858
59## Key setup59## Key setup
@@ -70,10 +70,10 @@
70try:70try:
71 pubkey = keys['nodekey'].publickey().exportKey()71 pubkey = keys['nodekey'].publickey().exportKey()
72except AttributeError:72except AttributeError:
73 raise libs.errors.DependancyError(_(73 raise Exception(_(
74 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))74 'Please update PyCrypto: https://www.dlitz.net/software/pycrypto/'))
75else:75else:
76 keys['nodekey'].hash = hashlib.sha256(pubkey).hexdigest()76 keys['nodekey'].hash = hashlib.sha256(pubkey).hexdigest()
7777
78print(_(' [*] Done. Key fingerprint:'))78print(_(' [*] Done. Key fingerprint:'))
79print(' %s' % keys['nodekey'].hash)79print(' %s' % keys['nodekey'].hash)
@@ -104,8 +104,8 @@
104 key_file.write(json.dumps(keys_by_hash, indent = 4))104 key_file.write(json.dumps(keys_by_hash, indent = 4))
105 key_file.close()105 key_file.close()
106except IOError:106except IOError:
107 print(_(' [*] Error writing %s. Check file permissions.' % KEY_PATH))107 print(_(' [*] Error writing %s. Check file permissions.' % KEYS_PATH))
108 raise libs.errors.InstallError(_('Could not write to %s.' % KEY_PATH))108 raise Exception(_('Could not write to %s.' % KEYS_PATH))
109109
110110
111## Configuration111## Configuration
@@ -126,16 +126,16 @@
126 config_file.close()126 config_file.close()
127except IOError as error:127except IOError as error:
128 print(_(' [*] Error writing %s. Check file permissions.' % CONFIG_PATH))128 print(_(' [*] Error writing %s. Check file permissions.' % CONFIG_PATH))
129 raise libs.errors.InstallError(_('Could not write to %s.' % CONFIG_PATH))129 raise Exception(_('Could not write to %s.' % CONFIG_PATH))
130130
131friendlistpath = os.path.join(VOMUN_PATH, 'friends.json')131friendlistpath = os.path.join(VOMUN_PATH, 'friends.json')
132try:132try:
133 friendlistr = open(friendlistpath, "r")133 friendlistr = open(friendlistpath, "r")
134 friendlistr.close()134 friendlistr.close()
135except IOError:135except IOError:
136 friendlistr = open(friendlistpath, "w")136 friendlistr = open(friendlistpath, "w")
137 friendlistr.write('[]')137 friendlistr.write('[]')
138 friendlistr.close()138 friendlistr.close()
139139
140## Setup complete140## Setup complete
141print(_(' == Setup Complete =='))141print(_(' == Setup Complete =='))

Subscribers

People subscribed via source and target branches

to all changes: