• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中settings.settings.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_groups_from_ldap

    def get_groups_from_ldap(username, password):

        # here deal with ldap to get user groups
        conn = get_ldap_connection()

        try:
            base_people = settings.get('ldap', 'base_people')
            base_group = settings.get('ldap', 'base_group')

            # authenticate user on ldap
            user_dn = "uid=%s,%s" % (username, base_people)
            conn.simple_bind_s(user_dn, password)

            print "User %s authenticated" % username

            # search for user's groups
            look_filter = "(|(&(objectClass=*)(member=%s)))" % (user_dn)
            results = conn.search_s(base_group,
                                    ldap.SCOPE_SUBTREE,
                                    look_filter, ['cn'])
            groups = [result[1]['cn'][0] for result in results]
            return groups

        except ldap.INVALID_CREDENTIALS:
            print "Authentication failed: username or password is incorrect."
            raise AuthenticationError

        except ldap.NO_SUCH_OBJECT as e:
            print "No result found: %s " + str(e)
            raise AuthenticationError

        finally:
            conn.unbind_s()
开发者ID:nealepetrillo,项目名称:slurm-web,代码行数:33,代码来源:auth.py


示例2: __init__

    def __init__(self, dbman, initialcmd):
        """
        :param dbman: :class:`~alot.db.DBManager`
        :param initialcmd: commandline applied after setting up interface
        :type initialcmd: str
        :param colourmode: determines which theme to chose
        :type colourmode: int in [1,16,256]
        """
        self.dbman = dbman

        colourmode = int(settings.get('colourmode'))
        logging.info('setup gui in %d colours' % colourmode)
        global_att = settings.get_theming_attribute('global', 'body')
        self.mainframe = urwid.Frame(urwid.SolidFill())
        self.mainframe_themed = urwid.AttrMap(self.mainframe, global_att)
        self.inputwrap = InputWrap(self, self.mainframe_themed)
        self.mainloop = urwid.MainLoop(self.inputwrap,
                handle_mouse=False,
                event_loop=urwid.TwistedEventLoop(),
                unhandled_input=self.unhandeled_input)
        self.mainloop.screen.set_terminal_properties(colors=colourmode)

        self.show_statusbar = settings.get('show_statusbar')
        self.notificationbar = None
        self.mode = 'global'
        self.commandprompthistory = []

        logging.debug('fire first command')
        self.apply_command(initialcmd)
        self.mainloop.run()
开发者ID:t-8ch,项目名称:alot,代码行数:30,代码来源:ui.py


示例3: traceFromExecutable

 def traceFromExecutable(self):
     if not settings.get('new trace', 'EXECUTABLE'):
         self.status("[!] No executable provided")
         return
     self.currentTrace = HeapTrace(self)
     self.currentTrace.run()
     self.status("Starting {}".format(settings.get('new trace', 'EXECUTABLE')))
开发者ID:Ramlak,项目名称:HeapTrace,代码行数:7,代码来源:main.py


示例4: auto_add

    def auto_add(self, mode, new_date = datetime.date.today()):
        # Check if we already have the current date in the file
        for line in self.lines:
            date_matches = self._match_date(line['text'])

            if date_matches is not None:
                date = self.process_date(date_matches)

                if date == new_date:
                    return

        if mode == settings.AUTO_ADD_OPTIONS['TOP']:
            self.lines.insert(0, {
                'text': '%s\n' %
                    new_date.strftime(settings.get('default', 'date_format')),
                'entry': None
            })
            self.lines.insert(1, {'text': '\n', 'entry': None})
        elif mode == settings.AUTO_ADD_OPTIONS['BOTTOM']:
            if len(self.lines) > 0:
                self.lines.append({'text': '\n', 'entry': None})

            self.lines.append({
                'text': '%s\n' %
                    new_date.strftime(settings.get('default', 'date_format')),
                'entry': None
            })
            self.lines.append({'text': '\n', 'entry': None})
开发者ID:waldvogel,项目名称:taxi,代码行数:28,代码来源:parser.py


示例5: get_postgresql_url

def get_postgresql_url():
    return 'postgres://{user}:{password}@{host}:{port}/{database}'.format(
        database=settings.get('database'),
        user=settings.get('user'),
        password=settings.get('password'),
        host=settings.get('host'),
        port=5432,
    )
开发者ID:vatseek,项目名称:flask_lessons,代码行数:8,代码来源:config.py


示例6: main

def main():
    # do some stuff to ensure that there are enough ball_entry's in the db

    import os
    import sys
    from sqlalchemy import create_engine

    default_url = settings.get('DATABASE_URL')
    db_url = os.environ.get("DATABASE_URL", default_url)

    engine = create_engine(db_url)
    engine.echo = False

    if 'wipe' in sys.argv:
        print('Wiping')
        wipe(engine)
        print('Done wiping')

    Session.configure(bind=engine)
    Base.metadata.create_all(engine)

    conn = engine.connect()

    try:
        from pprint import pprint as pp
        if 'interact' in sys.argv:
            ppl = lambda x: pp(list(x))

            import code
            l = globals()
            l.update(locals())
            code.interact(local=l)

        else:
            table_num = settings.get('table_num', 17)

            session = Session()

            query = session.query(BallTable)
            query = query.all()

            pp(query)

            existing_table_ids = [
                table.ball_table_num
                for table in query
            ]
            print('existing_table_ids:', existing_table_ids)

            for table_num in range(1, table_num + 1):
                if table_num not in existing_table_ids:
                    print('added;', table_num)
                    ball_table_insert = BallTable.__table__.insert({
                        'ball_table_name': 'Table {}'.format(table_num),
                        'ball_table_num': table_num})
                    engine.execute(ball_table_insert)
    finally:
        conn.close()
开发者ID:Mause,项目名称:table_select_web,代码行数:58,代码来源:db.py


示例7: calculateTangiblePositionAndRotationWithLiveIDs

	def calculateTangiblePositionAndRotationWithLiveIDs(self,id1,id2) :
		
		#translate from live ID to internal ID
		internalCursorID1 = self.externalIDtoTangibleCursorID(id1)
		internalCursorID2 = self.externalIDtoTangibleCursorID(id2)
		
		# create dictionary with live cursors

		liveCursors = {}
		for c in self.externalCursors:
			liveCursors[c.id] = c

		# calculate original rotation angle
		p1old = pointVector(self.tangibleCursors[internalCursorID1].offsetFromCenterX, self.tangibleCursors[internalCursorID1].offsetFromCenterY)
		p2old = pointVector(self.tangibleCursors[internalCursorID2].offsetFromCenterX, self.tangibleCursors[internalCursorID2].offsetFromCenterY)
		rotationAngleInCenteredTangible = calcClockWiseAngle(p1old,p2old)
		
		# calculate the current angle
		
		p1now = pointVector(liveCursors[id1].x, liveCursors[id1].y)
		p2now = pointVector(liveCursors[id2].x, liveCursors[id2].y)
		rotationAngleOfTangibleNow = calcClockWiseAngle(p1now, p2now);   
		
		# calculate the difference between the two angles
		currentRotation = clockwiseDifferenceBetweenAngles(rotationAngleInCenteredTangible, rotationAngleOfTangibleNow); 
		
		# check if the rotation filter is set to pre
		if settings.get('rotationFilterPosition') == 'pre':
			# add current rotation value to the rotation filter
			self.tangibleRotationFilter.addValue(currentRotation)
			# get rotation value from filter 
			currentRotation = self.tangibleRotationFilter.getState()
		
		# calculate the vector form current p1 to the tangible center
		shiftOfId1 = rotateVector(p1old, currentRotation)
		# calculate position
		currentPosition = p1now - shiftOfId1
		
		# check if the position filter is active
		if settings.get('positionFilterActive'):
			# add current position to filter
			self.tangiblePositionFilter.addXvalue(currentPosition.x)
			self.tangiblePositionFilter.addYvalue(currentPosition.y)
			# get position from filter
			currentPosition.x = self.tangiblePositionFilter.getXstate()
			currentPosition.y = self.tangiblePositionFilter.getYstate()
						
		# check if post rotation filter is active
		if settings.get('rotationFilterPosition') == 'post':
			# add current rotation value to the rotation filter
			self.tangibleRotationFilter.addValue(currentRotation)
			# get rotation value from filter 
			currentRotation = self.tangibleRotationFilter.getState()
		
		# set position and rotation
		self.position = currentPosition
		self.rotation = currentRotation	
开发者ID:hoshijirushi,项目名称:Vega,代码行数:57,代码来源:tangiblePattern.py


示例8: _create_from_cookie

    def _create_from_cookie(self, cookie):
        ''' Create session from jwt cookie

            Args:
            cookie: The cookie used to create session
        '''
        s = jwt.decode(cookie, settings.get('jwt_secret'), algorithms=[ settings.get('jwt_algorithm') ])
        self.id = s['id']
        self.username = s['username']
        self.exp = datetime.fromtimestamp(s['exp'], tz=timezone.utc) 
开发者ID:mkromkamp,项目名称:Device-cookies-example,代码行数:10,代码来源:session.py


示例9: __init__

 def __init__(self, xbee, dmxout):
     """
     :param n_sensor: number of sensor
     :return:
     """
     threading.Thread.__init__(self)
     self._must_stop = threading.Event()
     self._must_stop.clear()
     self.xbee = xbee
     self.sensors = SensorManager(tuple(settings.get("sensor", "addr")), dmxout)
     self._config_addr = str(settings.get("reconfig_addr"))
开发者ID:takuyozora,项目名称:wsnlight,代码行数:11,代码来源:wsn.py


示例10: getcmd

def getcmd(bits):
    final_cmd = ""
    pintool_path = os.path.join(ROOT_DIR, "lib/pintool/obj-{}/heaptrace.so".format(["", "ia32", "intel64"][bits/32]))
    pin_cmd = "pin -t {} -d 0 -p {} -- {}".format(pintool_path, int(settings.get('main', 'PIN_SERVER_PORT')),  settings.get('new trace', 'EXECUTABLE'))

    if settings.get('new trace', 'USE_TCP_WRAPPER') != 'False':
        final_cmd += settings.get('main', 'TCP_WRAPPER_COMMAND').replace('[CMD]', pin_cmd).replace('[PORT]', settings.get('new trace', 'TCP_WRAPPER_PORT'))
    else:
        final_cmd += settings.get('main', 'NEW_TERMINAL_COMMAND').replace('[CMD]', pin_cmd)

    return shlex.split(final_cmd)
开发者ID:Ramlak,项目名称:HeapTrace,代码行数:11,代码来源:misc.py


示例11: update

def update(options, args):
    """Usage: update

    Synchronizes your project database with the server."""

    db = ProjectsDb()

    db.update(
            settings.get('default', 'site'),
            settings.get('default', 'username'),
            settings.get('default', 'password')
    )
开发者ID:waldvogel,项目名称:taxi,代码行数:12,代码来源:app.py


示例12: registerCursors

	def registerCursors(self, *args,**kwargs):
		self.id = kwargs.get('id', 0)
		cursors = args[0]
		
		# set the center for tangible creation, if not provdided otherwise
		calibrationCenter = pointVector(settings.get('calibrationCenter')[0],settings.get('calibrationCenter')[1])
		
		# add points to dictionary
		for c in cursors:
				self.tangibleCursors[c.id] = tangibleCursor(x=c.x,y=c.y)
				self.tangibleCursors[c.id].calcOffset(calibrationCenter)
		# create triangles from points	
		self.tangibleTriangles = createTrianglesFromCursors(cursors)
开发者ID:hoshijirushi,项目名称:Vega,代码行数:13,代码来源:tangiblePattern.py


示例13: settingsRequest_handler

	def settingsRequest_handler(self,addr, tags, stuff, source):
		try:
			settingDict = settings.returnSettings()
			for key in settingDict:
				client = OSC.OSCClient()
				msg = OSC.OSCMessage()
				msg.setAddress("/vega/settings")
				msg.append(key)
				msg.append(settingDict[key])
				client.sendto(msg, (settings.get('remoteControlAddress'), settings.get('remoteControlPort')))

		except Exception, e:
			print 'Sending settings to control programm failed'
			print "Error:", e
开发者ID:hoshijirushi,项目名称:Vega,代码行数:14,代码来源:oscRemote.py


示例14: load_url

    def load_url(self, url):
        basename = os.path.basename(unicode(url.toString()))
        path = os.path.join(settings.get('help_path'), basename)

        if not os.path.exists(path):
            messagebox = RUrlLoadingErrorMessageBox(self)
            messagebox.exec_()
        else:
            if not url.scheme() in ['http', 'ftp']:
                url = QUrl(os.path.abspath(os.path.join(settings.get('help_path'), basename)).replace('\\', '/'))
                url.setScheme('file')
                self.ui.webView.load(url)
            else:
                messagebox = RUrlLoadingErrorMessageBox(self)
                messagebox.exec_()
开发者ID:tetra5,项目名称:radiance,代码行数:15,代码来源:RHelpViewerDialog.py


示例15: main

def main():
    parse_arguments()
    init_logging()
    models.initialize_database(settings["database"])

    command = settings.get("command", None)
    if command:
        run_command(command)
        return

    if settings.get("daemon", False):
        daemon = Daemon("/tmp/cachebrowser.pid", run_cachebrowser)
        daemon.start()
    else:
        run_cachebrowser()
开发者ID:hkplau,项目名称:cachebrowser,代码行数:15,代码来源:main.py


示例16: __init__

    def __init__(self, dbman, initialcmd):
        """
        :param dbman: :class:`~alot.db.DBManager`
        :param initialcmd: commandline applied after setting up interface
        :type initialcmd: str
        :param colourmode: determines which theme to chose
        :type colourmode: int in [1,16,256]
        """
        # store database manager
        self.dbman = dbman
        # define empty notification pile
        self._notificationbar = None
        # should we show a status bar?
        self._show_statusbar = settings.get("show_statusbar")
        # pass keypresses to the root widget and never interpret bindings
        self._passall = False
        # indicates "input lock": only focus move commands are interpreted
        self._locked = False
        self._unlock_callback = None  # will be called after input lock ended
        self._unlock_key = None  # key that ends input lock

        # alarm handle for callback that clears input queue (to cancel alarm)
        self._alarm = None

        # create root widget
        global_att = settings.get_theming_attribute("global", "body")
        mainframe = urwid.Frame(urwid.SolidFill())
        self.root_widget = urwid.AttrMap(mainframe, global_att)

        # set up main loop
        self.mainloop = urwid.MainLoop(
            self.root_widget,
            handle_mouse=False,
            event_loop=urwid.TwistedEventLoop(),
            unhandled_input=self._unhandeled_input,
            input_filter=self._input_filter,
        )

        # set up colours
        colourmode = int(settings.get("colourmode"))
        logging.info("setup gui in %d colours" % colourmode)
        self.mainloop.screen.set_terminal_properties(colors=colourmode)

        logging.debug("fire first command")
        self.apply_command(initialcmd)

        # start urwids mainloop
        self.mainloop.run()
开发者ID:teythoon,项目名称:alot,代码行数:48,代码来源:ui.py


示例17: get_auto_add_direction

def get_auto_add_direction(filepath, unparsed_filepath):
    try:
        auto_add = settings.get('default', 'auto_add')
    except ConfigParser.NoOptionError:
        auto_add = settings.AUTO_ADD_OPTIONS['AUTO']

    if auto_add == settings.AUTO_ADD_OPTIONS['AUTO']:
        if os.path.exists(filepath):
            auto_add = get_parser(filepath).get_entries_direction()
        else:
            auto_add = None

        if auto_add is not None:
            return auto_add

        # Unable to automatically detect the entries direction, we try to get a
        # previous file to see if we're lucky
        yesterday = datetime.date.today() - datetime.timedelta(days=30)
        oldfile = yesterday.strftime(os.path.expanduser(unparsed_filepath))

        if oldfile != filepath:
            try:
                oldparser = get_parser(oldfile)
                auto_add = oldparser.get_entries_direction()
            except ParseError:
                pass

    if auto_add is None:
        auto_add = settings.AUTO_ADD_OPTIONS['TOP']

    return auto_add
开发者ID:waldvogel,项目名称:taxi,代码行数:31,代码来源:app.py


示例18: __init

    def __init(self):
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint)
        
        ReportRegistry.reload()

        templates = {}
        for template_type, template_file in TEMPLATE_TYPES.iteritems():
            template_path = os.path.join(settings.get('template_path'), template_file)
            template = QtCore.QFile(template_path)
            if template.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text):
                template_str = unicode(QtCore.QString.fromUtf8(template.readAll()))
                templates.update({template_type: template_str})
                template.close()
        self.templates = templates
                
        items = [[report.date.strftime('%d.%m.%Y %H:%M:%S')] for report in ReportRegistry.itervalues()]
        
        if items:
            items.sort(reverse=True)
        else:
            self.ui.saveButton.setEnabled(False)
            
        self.model = GenericTableModel(items)
        self.ui.tableView.setModel(self.model)
        self.selection_model = self.ui.tableView.selectionModel()
        
        self.connect(self.selection_model, QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.show_report)
        
        self.ui.tableView.selectRow(0)
开发者ID:tetra5,项目名称:radiance,代码行数:29,代码来源:RReportViewerDialog.py


示例19: ping_handler

	def ping_handler(self,addr, tags, stuff, source):
		
		# save address where ping came from
		pingSource = OSC.getUrlStr(source).split(':')[0]
		if settings.get('remoteControlAddress') != pingSource:
			settings.set('remoteControlAddress',pingSource)
		
		# read the port of the remote control programm from settings
		port = settings.get('remoteControlPort')
		
		# send pong message back
		client = OSC.OSCClient()
		msg = OSC.OSCMessage()
		msg.setAddress("/vega/pong")
		msg.append(1234)
		client.sendto(msg, (pingSource, port))
开发者ID:hoshijirushi,项目名称:Vega,代码行数:16,代码来源:oscRemote.py


示例20: set_volume

 def set_volume(self):
     sfx = settings.get("sfx")
     self.sfx_suck.set_volume(sfx)
     self.sfx_click.set_volume(sfx)
     self.sfx_break.set_volume(sfx)
     self.sfx_push.set_volume(sfx)
     self.sfx_pickup.set_volume(sfx)
开发者ID:2028games,项目名称:PurpleFace,代码行数:7,代码来源:audio.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings.get_configdir函数代码示例发布时间:2022-05-27
下一篇:
Python logger.info函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap