From 67ff4428d52a50b74812e446ac81a124562fd118 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 28 Oct 2014 20:27:14 -0400 Subject: [PATCH] Fix up all python3 issues that do not have to do with text/bytes --- test/integration/Makefile | 3 +++ v2/ansible/parsing/vault/__init__.py | 4 ++-- v2/ansible/parsing/yaml/__init__.py | 2 +- v2/test/parsing/vault/test_vault.py | 6 +++--- v2/test/parsing/vault/test_vault_editor.py | 12 ++++++------ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/test/integration/Makefile b/test/integration/Makefile index 56e35d7c8b..6568c53017 100644 --- a/test/integration/Makefile +++ b/test/integration/Makefile @@ -38,6 +38,9 @@ unicode: non_destructive: ansible-playbook non_destructive.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) +mine: + ansible-playbook mine.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) + destructive: ansible-playbook destructive.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) diff --git a/v2/ansible/parsing/vault/__init__.py b/v2/ansible/parsing/vault/__init__.py index 506c0852f3..32a2727d33 100644 --- a/v2/ansible/parsing/vault/__init__.py +++ b/v2/ansible/parsing/vault/__init__.py @@ -507,7 +507,7 @@ class VaultAES256(object): # 1) nbits (integer) - Length of the counter, in bits. # 2) initial_value (integer) - initial value of the counter. "iv" from gen_key_initctr - ctr = Counter.new(128, initial_value=long(iv, 16)) + ctr = Counter.new(128, initial_value=int(iv, 16)) # AES.new PARAMETERS # 1) AES key, must be either 16, 24, or 32 bytes long -- "key" from gen_key_initctr @@ -542,7 +542,7 @@ class VaultAES256(object): return None # SET THE COUNTER AND THE CIPHER - ctr = Counter.new(128, initial_value=long(iv, 16)) + ctr = Counter.new(128, initial_value=int(iv, 16)) cipher = AES.new(key1, AES.MODE_CTR, counter=ctr) # DECRYPT PADDED DATA diff --git a/v2/ansible/parsing/yaml/__init__.py b/v2/ansible/parsing/yaml/__init__.py index 0acb77f8fd..c382282398 100644 --- a/v2/ansible/parsing/yaml/__init__.py +++ b/v2/ansible/parsing/yaml/__init__.py @@ -71,7 +71,7 @@ class DataLoader(): # if loading JSON failed for any reason, we go ahead # and try to parse it as YAML instead return self._safe_load(data) - except YAMLError, yaml_exc: + except YAMLError as yaml_exc: self._handle_error(yaml_exc, file_name, show_content) def load_from_file(self, file_name): diff --git a/v2/test/parsing/vault/test_vault.py b/v2/test/parsing/vault/test_vault.py index eb4df6ed90..d24573c729 100644 --- a/v2/test/parsing/vault/test_vault.py +++ b/v2/test/parsing/vault/test_vault.py @@ -125,7 +125,7 @@ class TestVaultLib(unittest.TestCase): error_hit = False try: enc_data = v.encrypt(data) - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True assert error_hit, "No error was thrown when trying to encrypt data with a header" @@ -137,7 +137,7 @@ class TestVaultLib(unittest.TestCase): error_hit = False try: dec_data = v.decrypt(data) - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True assert error_hit, "No error was thrown when trying to decrypt data without a header" @@ -150,7 +150,7 @@ class TestVaultLib(unittest.TestCase): error_hit = False try: enc_data = v.encrypt(data) - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True assert not error_hit, "An error was thrown when trying to encrypt data without the cipher set" assert v.cipher_name == "AES256", "cipher name is not set to AES256: %s" % v.cipher_name diff --git a/v2/test/parsing/vault/test_vault_editor.py b/v2/test/parsing/vault/test_vault_editor.py index 3396c6f8ab..8948fd7209 100644 --- a/v2/test/parsing/vault/test_vault_editor.py +++ b/v2/test/parsing/vault/test_vault_editor.py @@ -97,9 +97,9 @@ class TestVaultEditor(unittest.TestCase): # make sure the password functions for the cipher error_hit = False - try: + try: ve.decrypt_file() - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True # verify decrypted content @@ -125,9 +125,9 @@ class TestVaultEditor(unittest.TestCase): # make sure the password functions for the cipher error_hit = False - try: + try: ve.decrypt_file() - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True # verify decrypted content @@ -155,7 +155,7 @@ class TestVaultEditor(unittest.TestCase): error_hit = False try: ve.rekey_file('ansible2') - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True # verify decrypted content @@ -171,7 +171,7 @@ class TestVaultEditor(unittest.TestCase): error_hit = False try: dec_data = vl.decrypt(fdata) - except errors.AnsibleError, e: + except errors.AnsibleError as e: error_hit = True os.unlink(v10_file.name)