1+ import os
12import json
23import subprocess
34import pandas as pd
@@ -53,11 +54,12 @@ def execute_search(self, params):
5354 raise
5455
5556 def get_contentproviders (self ):
56- cmd = [self .command , "run_base_contentproviders.R" , self .wd ]
57+ runner = os .path .abspath (os .path .join (self .wd , "run_base_contentproviders.R" ))
58+ cmd = [self .command , runner , self .wd ]
5759 try :
5860 proc = subprocess .Popen (cmd , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
5961 encoding = 'utf-8' )
60- stdout , stderr = proc .communicate (json . dumps ({}) )
62+ stdout , stderr = proc .communicate ()
6163 output = [o for o in stdout .split ('\n ' ) if len (o ) > 0 ]
6264 error = [o for o in stderr .split ('\n ' ) if len (o ) > 0 ]
6365 raw = json .loads (output [- 1 ])
@@ -66,7 +68,7 @@ def get_contentproviders(self):
6668 else :
6769 contentproviders = pd .DataFrame (raw )
6870 res = {}
69- res ["contentproviders" ] = contentproviders
71+ res ["contentproviders" ] = contentproviders . to_json ( orient = 'records' )
7072 return res
7173 except Exception as e :
7274 self .logger .error (e )
@@ -93,10 +95,7 @@ def run(self):
9395 try :
9496 res = self .get_contentproviders ()
9597 res ["id" ] = k
96- if res .get ("status" ) == "error" or params .get ('raw' ) is True :
97- self .redis_store .set (k + "_output" , json .dumps (res ))
98- else :
99- self .redis_store .rpush ("input_data" , json .dumps (res ).encode ('utf8' ))
98+ self .redis_store .set (k + "_output" , json .dumps (res ))
10099 except Exception as e :
101100 self .logger .exception ("Exception during retrieval of contentproviders." )
102101 self .logger .error (params )
0 commit comments