Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit f8cde27

Browse files
committed
Move signer decision into import tree
1 parent 8ac3634 commit f8cde27

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

adb/adb_debug.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727

2828
try:
2929
import sign_m2crypto
30+
rsa_signer = sign_m2crypto.M2CryptoSigner
3031
except ImportError:
31-
sign_m2crypto = None
32-
try:
33-
import sign_pythonrsa
34-
except ImportError:
35-
sign_pythonrsa = None
32+
try:
33+
import sign_pythonrsa
34+
rsa_signer = sign_pythonrsa.PythonRSASigner.FromRSAKeyPath
35+
except ImportError:
36+
rsa_signer = None
3637

3738

3839
gflags.ADOPT_module_key_flags(common_cli)
@@ -47,14 +48,11 @@
4748

4849
def GetRSAKwargs():
4950
if FLAGS.rsa_key_path:
50-
if not sign_m2crypto and not sign_pythonrsa:
51+
if rsa_signer is None:
5152
print >> sys.stderr, 'Please install either M2Crypto or python-rsa'
5253
sys.exit(1)
53-
signer = (
54-
sign_m2crypto.M2CryptoSigner if sign_m2crypto
55-
else sign_pythonrsa.PythonRSASigner.FromRSAKeyPath)
5654
return {
57-
'rsa_keys': [signer(os.path.expanduser(path))
55+
'rsa_keys': [rsa_signer(os.path.expanduser(path))
5856
for path in FLAGS.rsa_key_path],
5957
'auth_timeout_ms': int(FLAGS.auth_timeout_s * 1000.0),
6058
}

0 commit comments

Comments
 (0)