use logger instead of print as often as possible
[myslice.git] / portal / slicetabexperiment.py
index 9eaaea7..138754a 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 # this somehow is not used anymore - should it not be ?
 from django.core.context_processors import csrf
 from django.http import HttpResponseRedirect
@@ -18,6 +16,7 @@ from myslice.configengine import ConfigEngine
 
 from myslice.theme import ThemeView
 from myslice.configengine import ConfigEngine
+from myslice.settings import logger
 
 from sfa.planetlab.plxrn import hash_loginbase
 
@@ -45,12 +44,8 @@ class ExperimentView (FreeAccessView, ThemeView):
         try:
             for resources in current_resources:
                 list_res = resources['resource']
-                #print "list_b4"
-                #print list_res
                 for res in list_res:
                     split_list = res.split('+') # split the resource urn
-                    #print "list_after"
-                    #print split_list
                     if [s for s in split_list if 'ple' in s]: # find ple resources
                         res_hrn = split_list[-1] # last element is resource hrn
                         ple_resource_list.append(res_hrn)
@@ -68,17 +63,17 @@ class ExperimentView (FreeAccessView, ThemeView):
                         nitos_resource_list.append(res_hrn)
 
 
-        except Exception,e:
-            print("Exception in slicetabexperiment.py in OneLab resource search %s" % e)
+        except Exception as e:
+            logger.error("Exception in slicetabexperiment.py in OneLab resource search {}".format(e))
         
-        #print "list of ple res hrns"
-        #print ple_resource_list
-        #print "list of nit_paris res hrns"
-        #print nitos_paris_resource_list
-        #print "list of iotLab res hrns"
-        #print iotlab_resource_list
-        #print "list of nitos res hrns"
-        #print nitos_resource_list
+        #logger.debug("list of ple res hrns")
+        #logger.debug(ple_resource_list)
+        #logger.debug("list of nit_paris res hrns")
+        #logger.debug(nitos_paris_resource_list)
+        #logger.debug("list of iotLab res hrns")
+        #logger.debug(iotlab_resource_list)
+        #logger.debug("list of nitos res hrns")
+        #logger.debug(nitos_resource_list)
 
         all_users = list() 
         #get all  iotlab users
@@ -94,7 +89,7 @@ class ExperimentView (FreeAccessView, ThemeView):
             res = urllib2.urlopen(req)
             all_users = json.load(res) 
         except urllib2.URLError as e:
-            print("There is a problem in getting iotlab users %s" % e.reason)
+            logger.error("There is a problem in getting iotlab users {}".format(e.reason))
        
 
         #getting the login from email