Esempio n. 1
0
 def check_user_updates(self,username):
     update_items = []
     dep=None
     try:
         from convirt.model import Deployment
         deps=DBSession.query(Deployment).all()
         if len(deps) > 0:
             dep=deps[0]
             user_config_filename=os.path.abspath(tg.config.get("user_config"))               
             if not os.path.exists(user_config_filename):
                 user_config_file=open(user_config_filename,"w")                   
                 user_config_file.close()                    
             user_config=PyConfig(filename=user_config_filename)
             date=user_config.get(username)               
             if date !=None:
                 p_r_date =  time.strptime(date, "%Y-%m-%d %H:%M:%S")                   
                 r_date =datetime(*p_r_date[0:5])
             else:
                 r_date=datetime.utcnow()
             edition = get_product_edition()
             (update_items,max_dt) = self.get_new_updates(dep.deployment_id,r_date, edition)
             user_config[username]=max_dt
             user_config.write()
         else:
             LOGGER.error("Deployment table is not set.Update can not proceed.")
             return
     except Exception, ex:
         traceback.print_exc()
         LOGGER.error("Error fetching updates:"+to_str(ex))
         return        
Esempio n. 2
0
 def check_user_updates(self, username):
     update_items = []
     dep = None
     try:
         from convirt.model import Deployment
         deps = DBSession.query(Deployment).all()
         if len(deps) > 0:
             dep = deps[0]
             user_config_filename = os.path.abspath(
                 tg.config.get("user_config"))
             if not os.path.exists(user_config_filename):
                 user_config_file = open(user_config_filename, "w")
                 user_config_file.close()
             user_config = PyConfig(filename=user_config_filename)
             date = user_config.get(username)
             if date != None:
                 p_r_date = time.strptime(date, "%Y-%m-%d %H:%M:%S")
                 r_date = datetime(*p_r_date[0:5])
             else:
                 r_date = datetime.utcnow()
             edition = get_product_edition()
             (update_items,
              max_dt) = self.get_new_updates(dep.deployment_id, r_date,
                                             edition)
             user_config[username] = max_dt
             user_config.write()
         else:
             LOGGER.error(
                 "Deployment table is not set.Update can not proceed.")
             return
     except Exception, ex:
         traceback.print_exc()
         LOGGER.error("Error fetching updates:" + to_str(ex))
         return