6
6
from packaging import version
7
7
import pdb
8
8
import shutil
9
+ import sys
9
10
import time
10
11
11
12
# django
@@ -36,7 +37,7 @@ class Command(BaseCommand):
36
37
37
38
38
39
# python path
39
- PYTHON_PATH = '/usr/local/anaconda/envs/combine/bin'
40
+ PYTHON_PATH = sys . executable . rstrip ( 'python' ). rstrip ( '/' )
40
41
41
42
42
43
def add_arguments (self , parser ):
@@ -110,10 +111,6 @@ def update(self, args, options):
110
111
# install requirements as combine user
111
112
os .system ('%s/pip install -r requirements.txt' % (self .PYTHON_PATH ))
112
113
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
-
117
114
# collect django static
118
115
os .system ('%s/python manage.py collectstatic --noinput' % (self .PYTHON_PATH ))
119
116
@@ -202,6 +199,9 @@ class VersionUpdateHelper(object):
202
199
Class to manage actions specific to version-to-version updates
203
200
'''
204
201
202
+ # python path
203
+ PYTHON_PATH = sys .executable .rstrip ('python' ).rstrip ('/' )
204
+
205
205
206
206
def __init__ (self ):
207
207
@@ -210,6 +210,7 @@ def __init__(self):
210
210
self .v0_4__set_job_baseline_combine_version ,
211
211
self .v0_4__update_transform_job_details ,
212
212
self .v0_4__set_job_current_combine_version ,
213
+ self .v0_7_1__fix_redis_version_mismatches
213
214
]
214
215
215
216
@@ -321,10 +322,26 @@ def v0_4__update_transform_job_details(self):
321
322
job .update_job_details ({'transformation' :trans_dict })
322
323
323
324
325
+ def v0_7_1__fix_redis_version_mismatches (self ):
326
+
327
+ '''
328
+ Method to fix any redis version mismatches
329
+ '''
324
330
331
+ if version .parse (settings .COMBINE_VERSION ) == version .parse ('v0.7' ):
325
332
333
+ logger .debug ('v0_7_1__fix_redis_version_mismatches: fixing redis versioning' )
326
334
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 ))
327
338
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 )
328
345
329
346
330
347
0 commit comments