66from packaging import version
77import pdb
88import shutil
9+ import sys
910import time
1011
1112# django
@@ -36,7 +37,7 @@ class Command(BaseCommand):
3637
3738
3839 # python path
39- PYTHON_PATH = '/usr/local/anaconda/envs/combine/bin'
40+ PYTHON_PATH = sys . executable . rstrip ( 'python' ). rstrip ( '/' )
4041
4142
4243 def add_arguments (self , parser ):
@@ -110,10 +111,6 @@ def update(self, args, options):
110111 # install requirements as combine user
111112 os .system ('%s/pip install -r requirements.txt' % (self .PYTHON_PATH ))
112113
113- # ensure redis version
114- os .system ('%s/pip uninstall redis -y' % (self .PYTHON_PATH ))
115- os .system ('%s/pip install redis==2.10.6' % (self .PYTHON_PATH ))
116-
117114 # collect django static
118115 os .system ('%s/python manage.py collectstatic --noinput' % (self .PYTHON_PATH ))
119116
@@ -202,6 +199,9 @@ class VersionUpdateHelper(object):
202199 Class to manage actions specific to version-to-version updates
203200 '''
204201
202+ # python path
203+ PYTHON_PATH = sys .executable .rstrip ('python' ).rstrip ('/' )
204+
205205
206206 def __init__ (self ):
207207
@@ -210,6 +210,7 @@ def __init__(self):
210210 self .v0_4__set_job_baseline_combine_version ,
211211 self .v0_4__update_transform_job_details ,
212212 self .v0_4__set_job_current_combine_version ,
213+ self .v0_7_1__fix_redis_version_mismatches
213214 ]
214215
215216
@@ -321,10 +322,26 @@ def v0_4__update_transform_job_details(self):
321322 job .update_job_details ({'transformation' :trans_dict })
322323
323324
325+ def v0_7_1__fix_redis_version_mismatches (self ):
326+
327+ '''
328+ Method to fix any redis version mismatches
329+ '''
324330
331+ if version .parse (settings .COMBINE_VERSION ) == version .parse ('v0.7' ):
325332
333+ logger .debug ('v0_7_1__fix_redis_version_mismatches: fixing redis versioning' )
326334
335+ # ensure redis version
336+ os .system ('%s/pip uninstall redis celery -y' % (self .PYTHON_PATH ))
337+ os .system ('%s/pip install redis==2.10.6 celery==4.3.0' % (self .PYTHON_PATH ))
327338
339+ # restart celery background tasks
340+ # get supervisor handle
341+ sp = SupervisorRPCClient ()
342+ # fire action
343+ results = sp .restart_process ('celery' )
344+ logger .debug (results )
328345
329346
330347
0 commit comments