Пример #1
0
    def check_for_updates(self, send_mail=False):
        update_items = []
        dep = None
        try:
            deps = DBSession.query(Deployment).all()
            if len(deps) > 0:
                dep = deps[0]
                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 None
        except Exception as ex:
            traceback.print_exc()
            LOGGER.error('Error fetching updates:' + to_str(ex))
            return None

        try:
            dep.update_checked_date = datetime.now()
            DBSession.add(dep)
        except:
            pass

        return update_items
Пример #2
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