Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit fc76b5c7 authored by Janez K's avatar Janez K
Browse files

executanje streamov

parent 7788d898
......@@ -5,4 +5,15 @@ class Command(NoArgsCommand):
help = 'check for streams that need to be executed and execute them'
option_list = NoArgsCommand.option_list
def handle_noargs(self, **options):
print 'test'
streams = Stream.objects.filter(active=True)
for stream in streams:
#preverimo ce je ze dost casa pretekl
import django
now = django.utils.timezone.now()
delta = now - stream.last_executed
delta_seconds = delta.seconds + delta.days * 86400
if delta_seconds > stream.period or 1==1:
stream.last_executed = now
stream.save()
print stream.execute()
......@@ -42,12 +42,14 @@ class Stream(models.Model):
#print for_input
finished = []
unfinished_list = []
halted = []
loop = True
while loop:
for w in unfinished_list:
# prepare all the inputs for this widget
input_dict = {}
output_dict = {}
output_dict = {}
finish = True
for i in w.inputs.all():
#gremo pogledat ce obstaja povezava in ce obstaja gremo value prebrat iz outputa
......@@ -70,10 +72,16 @@ class Stream(models.Model):
if w.abstract_widget.wsdl != '':
input_dict['wsdl']=w.abstract_widget.wsdl
input_dict['wsdl_method']=w.abstract_widget.wsdl_method
if w.abstract_widget.has_progress_bar:
output_dict = function_to_call(input_dict,w)
else:
output_dict = function_to_call(input_dict)
try:
if w.abstract_widget.has_progress_bar:
output_dict = function_to_call(input_dict,w)
elif w.abstract_widget.is_streaming:
output_dict = function_to_call(input_dict,w,self)
else:
output_dict = function_to_call(input_dict)
except:
halted.append(w)
finish=False
if w.type == 'subprocess':
......@@ -105,16 +113,17 @@ class Stream(models.Model):
value = None
output_dict[o.variable]=value
if w.type == 'output':
for i in w.inputs.all():
outputs[i.outer_output.pk]=(i.outer_output.variable,input_dict[i.variable])
if finish:
if w.type == 'output':
for i in w.inputs.all():
outputs[i.outer_output.pk]=(i.outer_output.variable,input_dict[i.variable])
if w.type != 'subprocess':
for o in w.outputs.all():
outputs[o.pk]=(o.variable,output_dict[o.variable])
if w.type != 'subprocess':
for o in w.outputs.all():
outputs[o.pk]=(o.variable,output_dict[o.variable])
finished.append(w.pk)
finished.append(w.pk)
unfinished_list = []
for w in widgets:
if not w.pk in finished:
......@@ -125,7 +134,8 @@ class Stream(models.Model):
ready_to_run = False
break
if ready_to_run:
unfinished_list.append(w)
if w not in halted:
unfinished_list.append(w)
if len(unfinished_list)==0:
loop = False
return outputs
......
......@@ -907,3 +907,34 @@ def sensitivity_analysis(input_dict):
def string_to_file(input_dict):
return {}
def rss_reader(input_dict,widget,stream):
import feedparser
from streams.models import StreamWidgetData
feed = feedparser.parse(input_dict['url'])
output_dict = {}
if stream is None:
output_dict['url'] = feed['items'][0]['link']
else:
try:
swd = StreamWidgetData.objects.get(stream=stream,widget=widget)
data = swd.value
except:
swd = StreamWidgetData()
swd.stream = stream
swd.widget = widget
data = []
swd.value = data
swd.save()
feed_length = len(feed['items'])
feed['items'].reverse()
for item in feed['items']:
if item['id'] not in data:
data.append(item['id'])
swd.value = data
swd.save()
output_dict['url'] = item['link']
break
raise Exception("Halting stream.")
return output_dict
\ No newline at end of file
......@@ -425,6 +425,8 @@ class Widget(models.Model):
input_dict['wsdl_method']=self.abstract_widget.wsdl_method
if self.abstract_widget.has_progress_bar:
outputs = function_to_call(input_dict,self)
elif self.abstract_widget.is_streaming:
outputs = function_to_call(input_dict,self,None)
else:
outputs = function_to_call(input_dict)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment