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


Python settings.get函数代码示例

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


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


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