Ejemplo n.º 1
0
 def check_user_updates(self, username):
     update_items = []
     dep = None
     try:
         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.now()
             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 None
     except Exception as ex:
         traceback.print_exc()
         LOGGER.error('Error fetching updates:' + to_str(ex))
         return None
     return update_items