当前位置: 首页>>代码示例>>Python>>正文


Python SystemOption.get方法代码示例

本文整理汇总了Python中models.SystemOption.get方法的典型用法代码示例。如果您正苦于以下问题:Python SystemOption.get方法的具体用法?Python SystemOption.get怎么用?Python SystemOption.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.SystemOption的用法示例。


在下文中一共展示了SystemOption.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: software_profile_create

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def software_profile_create():
    # if not can_create_user(current_user):
    #    abort(401)

    db_session = DBSession()

    form = SoftwareProfileForm(request.form)
    server_dialog_form = ServerDialogForm(request.form)

    fill_servers(server_dialog_form.server_dialog_server.choices, get_server_list(db_session), False)

    if request.method == 'POST' and form.validate():

        software_profile = get_software_profile(db_session, form.profile_name.data)

        if software_profile is not None:
            return render_template('conformance/profile_edit.html',
                                   form=form, system_option=SystemOption.get(db_session), duplicate_error=True)

        software_profile = SoftwareProfile(
            name=form.profile_name.data,
            description=form.description.data,
            packages=','.join([l for l in form.software_packages.data.splitlines() if l]),
            created_by=current_user.username)

        db_session.add(software_profile)
        db_session.commit()

        return redirect(url_for('conformance.home'))
    else:

        return render_template('conformance/profile_edit.html',
                               form=form, server_dialog_form=server_dialog_form,
                               system_option=SystemOption.get(db_session))
开发者ID:kstaniek,项目名称:csm,代码行数:36,代码来源:conformance.py

示例2: software_profile_edit

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def software_profile_edit(profile_name):
    db_session = DBSession()

    software_profile = get_software_profile(db_session, profile_name)
    if software_profile is None:
        abort(404)

    form = SoftwareProfileForm(request.form)
    server_dialog_form = ServerDialogForm(request.form)
    fill_servers(server_dialog_form.server_dialog_server.choices, get_server_list(db_session), False)

    if request.method == 'POST' and form.validate():
        if profile_name != form.profile_name.data and \
                        get_software_profile(db_session, form.profile_name.data) is not None:
            return render_template('conformance/profile_edit.html',
                                   form=form, server_dialog_form=server_dialog_form,
                                   system_option=SystemOption.get(db_session), duplicate_error=True)

        software_profile.name = form.profile_name.data
        software_profile.description = form.description.data
        software_profile.packages = ','.join([l for l in form.software_packages.data.splitlines() if l]),

        db_session.commit()

        return redirect(url_for('conformance.home'))
    else:
        form.profile_name.data = software_profile.name
        form.description.data = software_profile.description
        if software_profile.packages is not None:
            form.software_packages.data = '\n'.join(software_profile.packages.split(','))

    return render_template('conformance/profile_edit.html',
                           form=form, server_dialog_form=server_dialog_form,
                           system_option=SystemOption.get(db_session))
开发者ID:kstaniek,项目名称:csm,代码行数:36,代码来源:conformance.py

示例3: create_email_notification

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
    def create_email_notification(self, db_session, logger, host, install_job):
        try:
            session_log_link = "log/hosts/{}/install_job_history/session_log/{}?file_path={}".format(
                urllib.quote(host.hostname), install_job.id, install_job.session_log)

            message = '<html><head></head><body>'
            if install_job.status == JobStatus.COMPLETED:
                message += 'The scheduled installation for host "' + host.hostname + '" has COMPLETED.<br><br>'
            elif install_job.status == JobStatus.FAILED:
                message += 'The scheduled installation for host "' + host.hostname + '" has FAILED.<br><br>'

            message += 'Scheduled Time: ' + \
                       get_datetime_string(install_job.scheduled_time) + \
                       ' UTC<br>'
            message += 'Start Time: ' + \
                       get_datetime_string(install_job.start_time) + \
                       ' UTC<br>'
            message += 'Install Action: ' + install_job.install_action + '<br><br>'

            message = self.check_command_file_diff(install_job, message)

            session_log_url = SystemOption.get(db_session).base_url + '/' + session_log_link

            message += 'For more information, click the link below<br><br>'
            message += session_log_url + '<br><br>'

            if install_job.packages is not None and len(install_job.packages) > 0:
                message += 'Followings are the software packages: <br><br>' + install_job.packages.replace(',','<br>')

            message += '</body></html>'

            create_email_job(db_session, logger, message, install_job.created_by)

        except Exception:
            logger.exception('create_email_notification() hit exception')
开发者ID:smjurcak,项目名称:csm,代码行数:37,代码来源:install_work_unit.py

示例4: scheduling

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
    def scheduling(self, scheduler, daily_time):
        
        # First, re-set up the scheduler for the next day the same time. It is important to have
        # this logic on the top so that if any error encountered below, the scheduling still works.
        t = datetime.datetime.combine(datetime.datetime.now() + datetime.timedelta(days=1), daily_time)
        scheduler.enterabs(time.mktime(t.timetuple()), 1, self.scheduling, (scheduler, daily_time,))
            
        db_session = DBSession()
        
        try:
            system_option = SystemOption.get(db_session)
            
            # If software inventory is enabled, submit the inventory jobs
            if system_option.enable_inventory:
                inventory_jobs = db_session.query(InventoryJob).all()

                if len(inventory_jobs)> 0:
                    for inventory_job in inventory_jobs:
                        inventory_job.pending_submit = True
                    db_session.commit()
                        
            #Check if there is any housekeeping work to do
            self.perform_housekeeping_tasks(db_session, system_option)
            
        except:
            logger.exception('InventoryManagerScheduler hit exception')
        finally:
            db_session.close()
开发者ID:ommaurya,项目名称:csm,代码行数:30,代码来源:scheduler.py

示例5: run

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
 def run(self):
     db_session = DBSession()   
     try:         
         system_option = SystemOption.get(db_session)            
         inventory_hour = system_option.inventory_hour
         db_session.close()
                     
         # Build a scheduler object that will look at absolute times
         scheduler = sched.scheduler(time.time, time.sleep)
         current_hour = datetime.datetime.now().hour
 
         # Put task for today at the designated hour.
         daily_time = datetime.time(inventory_hour)
         
         # If the scheduled time already passed, schedule it for tomorrow
         if current_hour > inventory_hour:
             first_time = datetime.datetime.combine(datetime.datetime.now() + datetime.timedelta(days=1), daily_time)
         else:
             first_time = datetime.datetime.combine(datetime.datetime.now(), daily_time)
         
         scheduler.enterabs(time.mktime(first_time.timetuple()), 1,
             self.scheduling, (scheduler, daily_time,))
        
         scheduler.run()
         
     except:
         logger.exception('InventoryManagerScheduler hit exception')
         db_session.close()
开发者ID:ommaurya,项目名称:csm,代码行数:30,代码来源:scheduler.py

示例6: refresh_all

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
    def refresh_all(cls):
        """
        Retrieves all the catalog data and SMU XML file data and updates the database.
        """
        db_session = DBSession()
        
        catalog = SMUInfoLoader.get_catalog_from_cco()
        if len(catalog) > 0:
            system_option = SystemOption.get(db_session)
            try:
                # Remove all rows first
                db_session.query(CCOCatalog).delete()
            
                for platform in catalog:
                    releases = catalog[platform]
                    for release in releases:
                        cco_catalog = CCOCatalog(platform=platform,release=release)
                        db_session.add(cco_catalog)

                        SMUInfoLoader(platform, release)
                
                system_option.cco_lookup_time = datetime.datetime.utcnow()
                db_session.commit()
                return True
            except Exception:
                logger.exception('refresh_all() hit exception')
                db_session.rollback()  
            
        return False
开发者ID:smjurcak,项目名称:csm,代码行数:31,代码来源:smu_info_loader.py

示例7: host_urls

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
    def host_urls(self):
        system_option = SystemOption.get(self.db_session)
        if system_option.enable_user_credential_for_host:
            user = get_user_by_id(self.db_session, self.install_job.user_id)
            if user is not None:
                return self.make_urls(user.username, user.host_password)

        return self.make_urls()
开发者ID:kstaniek,项目名称:csm,代码行数:10,代码来源:base.py

示例8: __init__

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
 def __init__(self, name, num_threads=None):
     threading.Thread.__init__(self, name = name)
     
     if num_threads is None:
         num_threads = SystemOption.get(DBSession()).inventory_threads
     
     # Set up the thread pool
     self.pool = Pool(num_threads)
开发者ID:ommaurya,项目名称:csm,代码行数:10,代码来源:sim.py

示例9: optimize_software

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def optimize_software():
    server_dialog_form = ServerDialogForm(request.form)
    software_profile_form = SoftwareProfileForm(request.form)

    return render_template('cco/optimize_software.html',
                           server_dialog_form=server_dialog_form,
                           software_profile_form=software_profile_form,
                           system_option=SystemOption.get(DBSession()))
开发者ID:smjurcak,项目名称:csm,代码行数:10,代码来源:cco.py

示例10: __init__

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
 def __init__(self, name, num_threads=None):
     threading.Thread.__init__(self, name = name)
     
     db_session = DBSession()
     if num_threads is None:
         num_threads = SystemOption.get(db_session).install_threads
     
     # Set up the thread pool
     self.pool = Pool(num_threads)
开发者ID:ommaurya,项目名称:csm,代码行数:11,代码来源:sum.py

示例11: home

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def home(platform, release):
    system_option = SystemOption.get(DBSession())
    form = BrowseServerDialogForm(request.form)
    fill_servers(form.dialog_server.choices, get_server_list(DBSession()), False)
    export_software_information_form = ExportSoftwareInformationForm(request.form)

    return render_template('cco/home.html', form=form, platform=platform,
                           release=release, system_option=system_option,
                           export_software_information_form=export_software_information_form)
开发者ID:smjurcak,项目名称:csm,代码行数:11,代码来源:cco.py

示例12: make_urls

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
    def make_urls(self, preferred_host_username=None, preferred_host_password=None):
        urls = []

        if len(self.host.connection_param) > 0:
            connection = self.host.connection_param[0]
            jump_host_url = ''

            # Checks if there is a jump server
            if connection.jump_host_id is not None:
                try:
                    jump_host = self.db_session.query(JumpHost).filter(JumpHost.id == connection.jump_host_id).first()
                    if jump_host is not None:
                        jump_host_url = make_url(
                            connection_type=jump_host.connection_type,
                            host_username=jump_host.username,
                            host_password=jump_host.password,
                            host_or_ip=jump_host.host_or_ip,
                            port_number=jump_host.port_number)
                except:
                    pass

            host_username = connection.username
            host_password = connection.password

            if not is_empty(preferred_host_username) and not is_empty(preferred_host_password):
                host_username = preferred_host_username
                host_password = preferred_host_password
            else:
                system_option = SystemOption.get(self.db_session)
                if system_option.enable_default_host_authentication:
                    if not is_empty(system_option.default_host_username) and not is_empty(system_option.default_host_password):
                        if system_option.default_host_authentication_choice == DefaultHostAuthenticationChoice.ALL_HOSTS or \
                            (system_option.default_host_authentication_choice ==
                                DefaultHostAuthenticationChoice.HOSTS_WITH_NO_SPECIFIED_USERNAME_AND_PASSWORD and
                                is_empty(host_username) and
                                is_empty(host_password)):
                            host_username = system_option.default_host_username
                            host_password = system_option.default_host_password

            for host_or_ip in connection.host_or_ip.split(','):
                for port_number in connection.port_number.split(','):
                    host_urls = []
                    if not is_empty(jump_host_url):
                        host_urls.append(jump_host_url)

                    host_urls.append(make_url(
                        connection_type=connection.connection_type,
                        host_username=host_username,
                        host_password=host_password,
                        host_or_ip=host_or_ip,
                        port_number=port_number,
                        enable_password=connection.enable_password))

                    urls.append(host_urls)

        return urls
开发者ID:smjurcak,项目名称:csm,代码行数:58,代码来源:context.py

示例13: create_email_job_with_attachment_files

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def create_email_job_with_attachment_files(db_session, message, file_paths, recipients):
    system_option = SystemOption.get(db_session)
    if not system_option.enable_email_notify:
        return

    email_job = EmailJob(recipients=recipients, message=message, created_by=current_user.username,
                         attachment_file_paths=file_paths)
    db_session.add(email_job)
    db_session.commit()
    return
开发者ID:smjurcak,项目名称:csm,代码行数:12,代码来源:inventory.py

示例14: user_list

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def user_list():
    db_session = DBSession()

    users = get_user_list(db_session)
    if users is None:
        abort(404)

    if current_user.privilege == UserPrivilege.ADMIN:
        return render_template('user/index.html', users=users, system_option=SystemOption.get(db_session))

    return render_template('user/not_authorized.html', user=current_user)
开发者ID:smjurcak,项目名称:csm,代码行数:13,代码来源:authenticate.py

示例15: send_install_status_email

# 需要导入模块: from models import SystemOption [as 别名]
# 或者: from models.SystemOption import get [as 别名]
def send_install_status_email(install_job):
    db_session = DBSession
    username = install_job.created_by

    system_option = SystemOption.get(db_session)
    if not system_option.enable_email_notify:
        return
    
    smtp_server = get_smtp_server(db_session)
    if smtp_server is None:
        logger.error('mailer: SMTP Server has not been specified')
        return
    
    user = get_user(db_session, username)
    if user is None:
        logger.error('mailer: Unable to locate user "%s"' % username)
        return
    
    host = get_host(db_session, install_job.host_id)
    if host is None:
        logger.error('mailer: Unable to locate host id "%s"' % str(install_job.host_id))
        return
    
    message = '<html><head><body>'
    if install_job.status == JobStatus.COMPLETED:
        message += 'The scheduled installation for host "' + host.hostname + '" has COMPLETED<br><br>'
    elif install_job.status == JobStatus.FAILED:
        message += 'The scheduled installation for host "' + host.hostname + '" has FAILED<br><br>'
    
    message += 'Scheduled Time: ' + get_datetime_string(install_job.scheduled_time) + ' (UTC)<br>'    
    message += 'Start Time: ' + get_datetime_string(install_job.start_time) + ' (UTC)<br>'
    message += 'Install Action: ' + install_job.install_action + '<br><br>'
    
    session_log_url = system_option.base_url + '/' + get_session_log_link(host, install_job)
    
    message += 'For more information, click the link below<br><br>'
    message += session_log_url + '<br><br>'
    
    if install_job.packages is not None and len(install_job.packages) > 0:
        message += 'Followings are the software packages: <br><br>' + install_job.packages.replace(',','<br>')
        
    message += '</body></head></html>'
    
    sendmail(
        server=smtp_server.server, 
        server_port=smtp_server.server_port,
        sender=smtp_server.sender,
        recipient=user.email,
        message=message,
        use_authentication=smtp_server.use_authentication,
        username=smtp_server.username,
        password=smtp_server.password,
        secure_connection=smtp_server.secure_connection)
开发者ID:ponnadarahul,项目名称:csm,代码行数:55,代码来源:mailer.py


注:本文中的models.SystemOption.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。