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


Python util.Hashtable类代码示例

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


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

示例1: hashtable

def hashtable(*key_values):
    """
    :param key_values: 2-tuples of (key, value)
    :return: initialized Hashtable
    """
    ht = Hashtable()
    for k, v in key_values:
        ht.put(k, v)
    return ht
开发者ID:ralle12345,项目名称:openhab-jython,代码行数:9,代码来源:binding.py

示例2: lookup

 def lookup(self, ejbName):
     properties = Hashtable();
     properties.put(FACTORY_INITIAL_KEY, FACTORY_INITIAL_VALUE);
     properties.put(FACTORY_URLPKGS_KEY, FACTORY_URLPKGS_VALUE);
     properties.put(PROVIDER_URL_KEY, PROVIDER_URL_VALUE);
     
     mylookup = None
     try:
         context = InitialContext(properties);
         mylookup = context.lookup(ejbName)
     except NoInitialContextException, err:
         raise Exception("Error with EJB connection[localhost:1099]\n" + str(err))
开发者ID:rafaelnunes,项目名称:jython-examples,代码行数:12,代码来源:ejb_tests.py

示例3: lookup

def lookup(ejbName):
    properties = Hashtable();
    properties.put(lookup_properties.FACTORY_INITIAL_KEY, lookup_properties.FACTORY_INITIAL_VALUE);
    properties.put(lookup_properties.FACTORY_URLPKGS_KEY, lookup_properties.FACTORY_URLPKGS_VALUE);
    properties.put(lookup_properties.PROVIDER_URL_KEY, lookup_properties.PROVIDER_URL_VALUE);
    
    context = InitialContext(properties);
    mylookup = None
    try:
        mylookup = context.lookup(ejbName)
    except CommunicationException, err:
        raise Exception("Error with EJB connection[" + settings.SERVIDOR + ":1099]\n" + str(err))
开发者ID:rafaelnunes,项目名称:jython-examples,代码行数:12,代码来源:service_locator.py

示例4: fetch_ldap_group

  def fetch_ldap_group(self, file):
    """
    fetch group mapping from group ldap server
    :param file: output file name
    """
    self.logger.info("Fetching ldap groups")
    settings = Hashtable()
    settings.put(Context.INITIAL_CONTEXT_FACTORY, self.args[Constant.LDAP_GROUP_CONTEXT_FACTORY_KEY])
    settings.put(Context.PROVIDER_URL, self.args[Constant.LDAP_GROUP_CONTEXT_PROVIDER_URL_KEY])
    settings.put(Context.SECURITY_PRINCIPAL, self.args[Constant.LDAP_GROUP_CONTEXT_SECURITY_PRINCIPAL_KEY])
    settings.put(Context.SECURITY_CREDENTIALS, self.args[Constant.LDAP_GROUP_CONTEXT_SECURITY_CREDENTIALS_KEY])

    ctx = InitialDirContext(settings)
    search_target = "(objectClass=posixGroup)"
    return_attributes_standard = ['group_id', 'member_ids']
    return_attributes_actual = json.loads(self.args[Constant.LDAP_GROUP_SEARCH_RETURN_ATTRS_KEY])
    return_attributes_map = dict(zip(return_attributes_standard, return_attributes_actual))
    ctls = SearchControls()
    ctls.setReturningAttributes(return_attributes_actual)
    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE)

    ldap_records = []
    org_units = json.loads(self.args[Constant.LDAP_GROUP_SEARCH_DOMAINS_KEY])
    for search_unit in org_units:
      results = ctx.search(search_unit, search_target, ctls)
      for r in results:
        person_attributes = r.getAttributes()
        group = person_attributes.get(return_attributes_map['group_id']).get(0)
        group = re.sub(r"\r|\n", '', group).strip().encode('utf8')
        # skip special group that contains all group users
        if group == 'users':
          continue
        members = person_attributes.get(return_attributes_map['member_ids'])
        if members:
          self.group_map[group] = members
          sort_id = 0
          for member in members.getAll():
            member = re.sub(r"\r|\n", '', member).strip().encode('utf8')
            ldap_group_tuple = [self.group_app_id]
            ldap_group_tuple.append(group)
            ldap_group_tuple.append(sort_id)
            if member in self.ldap_user:
              ldap_group_tuple.append(self.app_id)
            else:
              ldap_group_tuple.append(self.group_app_id)
            ldap_group_tuple.append(member)
            ldap_group_tuple.append(self.wh_exec_id)
            ldap_records.append(ldap_group_tuple)
            sort_id += 1
        else:
          pass
    self.logger.info("%d records found in group accounts" % (len(self.group_map)))

    csv_writer = csv.writer(open(file, "w"), delimiter='\x1a', quoting=csv.QUOTE_MINIMAL, lineterminator="\n")
    csv_writer.writerows(ldap_records)
开发者ID:alyiwang,项目名称:WhereHows,代码行数:55,代码来源:LdapExtract.py

示例5: __init__

    def __init__(self, debugger):
        self.lastValue = None
        self.debugger = debugger
        MAX_SPEED = debugger.MAX_SPEED
        self.slider = swing.JSlider(swing.JSlider.HORIZONTAL, 0, MAX_SPEED,
                                    self.debugger.speed,
                                    stateChanged=self.stateChanged)
        self.last_speed = self.debugger.speed
        labels = Hashtable()
        labels.put(0, swing.JLabel('slow'))
        labels.put(MAX_SPEED, swing.JLabel('fast'))
        self.slider.labelTable = labels
        self.slider.paintLabels = 1

        self.addButton = swing.JButton(swing.ImageIcon('images/plus.jpg'),
                                       actionPerformed=self.actionPerformed,
                                       toolTipText='add Variable',
                                       preferredSize=BUTTON_SIZE)
        self.deleteButton = swing.JButton(swing.ImageIcon('images/minus.jpg'),
                                       actionPerformed=self.actionPerformed,
                                       toolTipText='remove Variable',
                                       preferredSize=BUTTON_SIZE)
        self.stepButton = swing.JButton(swing.ImageIcon('images/boot.jpg'),
                                        actionPerformed=self.actionPerformed,
                                        toolTipText='step',
                                        preferredSize=BUTTON_SIZE)
	self.pauseIcon = swing.ImageIcon('images/pause.jpg')
	self.runIcon = swing.ImageIcon('images/run.jpg')
        self.runButton = swing.JButton(self.runIcon,
                                        actionPerformed=self.actionPerformed,
                                        toolTipText='run',
                                       preferredSize=BUTTON_SIZE)
        self.fullspeedButton = swing.JButton(swing.ImageIcon('images/fullspeed.jpg'),
                                        actionPerformed=self.actionPerformed,
                                        toolTipText='full speed',
                                       preferredSize=BUTTON_SIZE)
        self.stopButton = swing.JButton(swing.ImageIcon('images/stop.jpg'),
                                        actionPerformed=self.actionPerformed,
                                        toolTipText='stop',
                                        preferredSize=BUTTON_SIZE)
        self.setLayout(swing.BoxLayout(self, swing.BoxLayout.X_AXIS))
        self.add(self.slider)
        self.add(self.addButton)
        self.add(self.deleteButton)
        #self.add(self.stepButton) # These two lines commented out by Brian O because of removed Pause functionality -- 23 June 2008
        #self.add(self.runButton)
        self.add(self.fullspeedButton)
        self.add(self.stopButton)
	self.initialButtonState()
开发者ID:Bail-jw,项目名称:mediacomp-jes,代码行数:49,代码来源:JESDBVariableWatcher.py

示例6: getdata

def getdata():
	defaultResultText = "Decoding Failed"
	
	qread = QRCodeReader()
	ip = IJ.getProcessor()
	myimg = ip.getBufferedImage()
	source = BufferedImageLuminanceSource(myimg)
	bitmap = BinaryBitmap(HybridBinarizer(source))
	resultText = defaultResultText
	try :
		hints = Hashtable()
		hints.put(DecodeHintType.TRY_HARDER, True)
		result = qread.decode(bitmap, hints)
		resultText = result.getText()
	except NotFoundException, ex:
		print ex
开发者ID:pushkarparanjpe,项目名称:imagej-qr-decoder,代码行数:16,代码来源:QR_Decoder.py

示例7: __init__

 def __init__(self,url):
     env = Hashtable()
     env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
     env.put(Context.SECURITY_AUTHENTICATION, "none")
     env.put(Context.PROVIDER_URL, url)
     ctx = InitialDirContext(env)
     self.ctx = ctx
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:7,代码来源:UserLookupLDAP.py

示例8: initConnection

def initConnection(hostname, port, username, password):
	serviceURL = JMXServiceURL("t3", hostname, port,"/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
	h=Hashtable()
	h.put(Context.SECURITY_PRINCIPAL, username)
	h.put(Context.SECURITY_CREDENTIALS, password)
	h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")
	return JMXConnectorFactory.connect(serviceURL, h)
开发者ID:eldereis,项目名称:intelijans,代码行数:7,代码来源:import-mod.py

示例9: test_hashtable

 def test_hashtable(self):
     x = Hashtable()
     x.put('a', 1)
     x.put('b', 2)
     x.put('c', 3)
     x.put((1,2), "xyz")
     y = dict(x)
     self.assertEqual(set(y.items()), set([('a', 1), ('b', 2), ('c', 3), ((1,2), "xyz")]))
开发者ID:EnviroCentre,项目名称:jython-upgrade,代码行数:8,代码来源:test_dict_jy.py

示例10: __init__

 def __init__(self, *arg):
     """
     Return Surface that is subclassed from java.awt.image.BufferedImage.
     
     Alternative arguments:
     
     * Size (w,h) of surface, optional second argument of flags (SRCALPHA)
     * Bufferedimage to convert to Surface
     
     Module initialization places pyj2d.Surface in module's namespace.
     """
     try:
         width, height = arg[0]
         try:
             if arg[1] & (BufferedImage.TYPE_INT_ARGB | Const.SRCALPHA):
                 BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_ARGB)
             else:
                 BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_RGB)
         except IndexError:
             BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_ARGB)
             graphics2D = self.createGraphics()
             graphics2D.setColor(Color(0,0,0))
             graphics2D.fillRect(0, 0, width, height)
             graphics2D.dispose()
     except TypeError:
         try:
             cm = arg[0].getColorModel()
             raster = arg[0].getRaster()
             isRasterPremultiplied = arg[0].isAlphaPremultiplied()
             properties = Hashtable()
             keys = arg[0].getPropertyNames()
             if keys != None:
                 for key in keys:
                     properties.put(key,arg[0].getProperty(key))
         except AttributeError:
             cm, raster, isRasterPremultiplied, properties = arg
         BufferedImage.__init__(self, cm, raster, isRasterPremultiplied, properties)
     self._display = None    #display surface
     self._super_surface = None
     self._offset = (0,0)
     self._colorkey = None
     self._nonimplemented_methods()
开发者ID:jggatc,项目名称:pyj2d,代码行数:42,代码来源:surface.py

示例11: main

def main():
	try:
		record = "A"
		if("record_type" in globals()):
			record = str(record_type)
			
		timer = Timer()
		env = Hashtable()		
		env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory")
		env.put("java.naming.provider.url", "dns://" + dns_server)
		ictx = InitialDirContext(env)	
		attrs = ictx.getAttributes(hostname, [record])
		attr = attrs.get(record)
		result.value = timer.stop()
		result.status = result.STATUS_GOOD
		result.msg = "Query result: " + attr.toString()
		ictx.close()
	except NamingException, e:
		ictx.close()
		result.status = result.STATUS_FAILED
		result.msg = str(e.getMessage())
开发者ID:benc-uk,项目名称:ziz,代码行数:21,代码来源:dns.py

示例12: ssh

 def ssh(host, usr, pwd, timeout):
     jsch = JSch()
     session = jsch.getSession(usr, host, 22)
     session.setPassword(pwd)
     config = Hashtable()
     config.put('StrictHostKeyChecking', 'no')
     session.setConfig(config)
     session.setDaemonThread(True)
     ''' connect timeout '''
     session.connect(timeout*1000)
     
     channel = session.openChannel('shell')
     channel.setPtyType('vt102')
     
     env = Hashtable()
     channel.setEnv(env)
     
     expect4j = Expect4j(channel.getInputStream(), channel.getOutputStream())
     
     ''' expect return timeout '''
     channel.connect(timeout*1000)
     
     return expect4j
开发者ID:huhe56,项目名称:nsm-rest-api,代码行数:23,代码来源:myExpect.py

示例13: copy

 def copy(self):
     """
     Return Surface that is a copy of this surface.
     """
     if not self._super_surface:
         img_properties = Hashtable()
         keys = self.getPropertyNames()
         if keys != None:
             for key in keys:
                 img_properties.put(key,self.getProperty(key))
         surface = Surface(
                           self.getColorModel(),
                           self.getData(),
                           self.isAlphaPremultiplied(),
                           img_properties
                          )
         surface._colorkey = self._colorkey
     else:
         surface = Surface((self.width,self.height), BufferedImage.TYPE_INT_ARGB)
         g2d = surface.createGraphics()
         g2d.drawImage(self, 0, 0, None)
         g2d.dispose()
         surface._colorkey = self._colorkey
     return surface
开发者ID:jggatc,项目名称:pyj2d,代码行数:24,代码来源:surface.py

示例14: createLdapContext

	def createLdapContext(cls):
		Log.logMsg(5, "Creating ldap context")
		if cls.cf is None:
			raise Exception("Ldap not initialized")

		env=Hashtable()
		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory")
		env.put(Context.PROVIDER_URL, 'ldapi:///opt/zimbra/openldap/var/run/ldapi/') 
		env.put(Context.SECURITY_AUTHENTICATION, "simple")
		env.put(Context.SECURITY_PRINCIPAL, "cn=config")
		env.put(Context.SECURITY_CREDENTIALS, cls.cf.ldap_root_password)
		cls.mLdapContext = InitialDirContext(env)

		if cls.cf.ldap_is_master:
			#s = SearchControls()
			#s.setSearchScope(SearchControls.OBJECT_SCOPE)
			Log.logMsg(5, "Creating ldap context")
			ats = BasicAttributes("objectClass", None)
			atr = ['1.1']
			results = cls.mLdapContext.search("cn=accesslog", ats, atr)
			if results.hasMore():
				Log.logMsg(5, "Ldap config is master")
				cls.master = True
开发者ID:Deelight-fr,项目名称:Zimbra-1,代码行数:23,代码来源:ldap.py

示例15: fetch_ldap_user

  def fetch_ldap_user(self, file):
    """
    fetch ldap user from ldap server
    :param file: output file name
    """

    # Setup LDAP Context Options
    settings = Hashtable()
    settings.put(Context.INITIAL_CONTEXT_FACTORY, self.args[Constant.LDAP_CONTEXT_FACTORY_KEY])
    settings.put(Context.PROVIDER_URL, self.args[Constant.LDAP_CONTEXT_PROVIDER_URL_KEY])
    settings.put(Context.SECURITY_PRINCIPAL, self.args[Constant.LDAP_CONTEXT_SECURITY_PRINCIPAL_KEY])
    settings.put(Context.SECURITY_CREDENTIALS, self.args[Constant.LDAP_CONTEXT_SECURITY_CREDENTIALS_KEY])

    # page the result, each page have fix number of records
    pageSize = 5000
    pageControl = PagedResultsControl(pageSize, Control.NONCRITICAL)
    c_array = array([pageControl], Control)

    # Connect to LDAP Server
    ctx = InitialLdapContext(settings, None)
    ctx.setRequestControls(c_array)

    # load the java Hashtable out of the ldap server
    # Query starting point and query target
    search_target = '(objectClass=person)'
    return_attributes_standard = ['user_id', 'distinct_name', 'name', 'display_name', 'title', 'employee_number',
                                  'manager', 'mail', 'department_number', 'department', 'start_date', 'mobile']
    return_attributes_actual = json.loads(self.args[Constant.LDAP_SEARCH_RETURN_ATTRS_KEY])
    return_attributes_map = dict(zip(return_attributes_standard, return_attributes_actual))

    ctls = SearchControls()
    ctls.setReturningAttributes(return_attributes_actual)
    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE)
    ldap_records = []

    # domain format should look like : ['OU=domain1','OU=domain2','OU=domain3,OU=subdomain3']
    org_units = json.loads(self.args[Constant.LDAP_SEARCH_DOMAINS_KEY])

    cookie = None
    for search_unit in org_units:
      # pagination
      while True:
        # do the search
        search_result = ctx.search(search_unit, search_target, ctls)
        for person in search_result:
          ldap_user_tuple = [self.app_id]
          if search_unit == self.args[Constant.LDAP_INACTIVE_DOMAIN_KEY]:
            ldap_user_tuple.append('N')
          else:
            ldap_user_tuple.append('Y')
          person_attributes = person.getAttributes()
          user_id = person_attributes.get(return_attributes_map['user_id'])
          user_id = re.sub(r"\r|\n", '', user_id.get(0)).strip().encode('utf8')
          self.ldap_user.add(user_id)

          for attr_name in return_attributes_actual:
            attr = person_attributes.get(attr_name)
            if attr:
              attr = re.sub(r"\r|\n", '', attr.get(0)).strip().encode('utf8')
              # special fix for start_date
              if attr_name == return_attributes_map['start_date'] and len(attr) == 4:
                attr += '0101'
              ldap_user_tuple.append(attr)
            else:
              ldap_user_tuple.append("")

          ldap_user_tuple.append(self.wh_exec_id)
          ldap_records.append(ldap_user_tuple)

        # Examine the paged results control response
        control = ctx.getResponseControls()[0] # will always return a list, but only have one item
        if isinstance(control, PagedResultsResponseControl):
          cookie = control.getCookie()

        # Re-activate paged results
        if cookie is None:
          # reset ctx, break while loop, do next search
          pageControl = PagedResultsControl(pageSize, Control.NONCRITICAL)
          c_array = array([pageControl], Control)
          ctx.setRequestControls(c_array)
          break
        else:
          self.logger.debug("Have more than one page of result when search " + search_unit)
          pageControl = PagedResultsControl(pageSize, cookie, Control.CRITICAL)
          c_array = array([pageControl], Control)
          ctx.setRequestControls(c_array)

    self.logger.info("%d records found in ldap search" % (len(self.ldap_user)))

    csv_writer = csv.writer(open(file, "w"), delimiter='\x1a', quoting=csv.QUOTE_MINIMAL, lineterminator="\n")
    csv_writer.writerows(ldap_records)
开发者ID:linwenxue,项目名称:WhereHows,代码行数:91,代码来源:LdapExtract.py


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