예제 #1
0
    def check_for_updates(self, send_mail=False):

        update_items = []
        dep = None
        try:
            from convirt.model import Deployment
            deps = DBSession.query(Deployment).all()
            if len(deps) > 0:
                dep = deps[0]
                #update_items=retrieve_updates(dep.deployment_id)
                edition = get_product_edition()
                (new_updates,
                 max_dt) = self.get_new_updates(dep.deployment_id,
                                                dep.update_checked_date,
                                                edition)

                if send_mail and new_updates:
                    self.send_update_mails(new_updates)
            else:
                LOGGER.error(
                    "Deployment table is not set. Update can not proceed.")
                return update_items
        except Exception, ex:
            traceback.print_exc()
            LOGGER.error("Error fetching updates:" + to_str(ex))
            return update_items
예제 #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        
예제 #3
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
예제 #4
0
    def check_for_updates(self,send_mail=False):

        update_items = []
        dep=None
        try:
            from convirt.model import Deployment
            deps=DBSession.query(Deployment).all()
            if len(deps) > 0:
                dep=deps[0]
                #update_items=retrieve_updates(dep.deployment_id)
                edition = get_product_edition()
                (new_updates,max_dt)=self.get_new_updates(dep.deployment_id,dep.update_checked_date, edition)

                if send_mail and new_updates :
                    self.send_update_mails(new_updates)
            else:
                LOGGER.error("Deployment table is not set. Update can not proceed.")
                return update_items
        except Exception, ex:
            traceback.print_exc()
            LOGGER.error("Error fetching updates:"+to_str(ex))
            return update_items