Adapt code to python3.4 and add it to travis
Added to travis explicitly python 2.7, 3.4, 3.5, 3.6
This commit is contained in:
1 parent
7143baedc7
commit
174bb19319
4 files changed
+25
-11
No files matched your search
@@ -1,4 +1,9 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
script:
|
||||
- py.test
|
||||
install:
|
||||
|
||||
@@ -1 +1 @@
|
||||
from migration_linter import * # noqa
|
||||
from .migration_linter import * # noqa
|
||||
@@ -35,6 +35,10 @@ def has_default(sql, **kwargs):
|
||||
return False # Never fails
|
||||
|
||||
|
||||
def clean_bytes_to_str(byte_input):
|
||||
return byte_input.decode('utf-8').strip()
|
||||
|
||||
|
||||
class MigrationLinter:
|
||||
MIGRATION_FOLDER_NAME = 'migrations'
|
||||
|
||||
@@ -83,8 +87,8 @@ class MigrationLinter:
|
||||
git_init_cmd = 'cd {0} && git rev-list HEAD | tail -n 1'.format(
|
||||
self.location)
|
||||
process = Popen(git_init_cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
for line in process.stdout.readlines():
|
||||
self.commit_id = line.strip()
|
||||
for line in map(clean_bytes_to_str, process.stdout.readlines()):
|
||||
self.commit_id = line
|
||||
break
|
||||
process.wait()
|
||||
log.info('Operating until git identifier {0}'.format(self.commit_id))
|
||||
@@ -95,17 +99,17 @@ class MigrationLinter:
|
||||
log.info('Executing {0}'.format(git_diff_command))
|
||||
diff_process = Popen(
|
||||
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
for line in diff_process.stdout.readlines():
|
||||
for line in map(clean_bytes_to_str, diff_process.stdout.readlines()):
|
||||
# Only gather lines that include migrations
|
||||
if re.search(
|
||||
'\/{0}\/.*\.py'.format(self.MIGRATION_FOLDER_NAME),
|
||||
line) and \
|
||||
'__init__' not in line:
|
||||
self.changed_migration_files.append(line.strip())
|
||||
self.changed_migration_files.append(line)
|
||||
diff_process.wait()
|
||||
if diff_process.returncode != 0:
|
||||
output = []
|
||||
for line in diff_process.stderr.readlines():
|
||||
for line in map(clean_bytes_to_str, diff_process.stderr.readlines()):
|
||||
output.append(line)
|
||||
log.info("Error while git diff command:\n{}".format(
|
||||
"".join(output)))
|
||||
@@ -180,14 +184,14 @@ class MigrationLinter:
|
||||
'--database {3}').format(
|
||||
self.location, app_name, migration_name, self.database)
|
||||
log.info('Executing {0}'.format(git_diff_command))
|
||||
diff_process = Popen(
|
||||
sqlmigrate_process = Popen(
|
||||
git_diff_command, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
sql_statements = []
|
||||
for line in diff_process.stdout.readlines():
|
||||
for line in map(clean_bytes_to_str, sqlmigrate_process.stdout.readlines()):
|
||||
if not line.startswith('--'): # Ignore comments
|
||||
sql_statements.append(line.strip())
|
||||
diff_process.wait()
|
||||
if diff_process.returncode != 0:
|
||||
sql_statements.append(line)
|
||||
sqlmigrate_process.wait()
|
||||
if sqlmigrate_process.returncode != 0:
|
||||
raise RuntimeError('sqlmigrate command failed')
|
||||
log.info('Found {0} sql migration lines'.format(len(sql_statements)))
|
||||
return sql_statements
|
||||
|
||||
@@ -59,7 +59,12 @@ setup(
|
||||
'Environment :: Web Environment',
|
||||
'Framework :: Django',
|
||||
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
]
|
||||
)
|
||||
Reference in new issue
Block a user