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


Python device.Device类代码示例

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


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

示例1: getDeviceForDynAnalysis

def getDeviceForDynAnalysis():
    dev_list = Device.get_devices_list()
    
    devNum = len(dev_list)
    
    if devNum <= 0:
        logger.error("No device has been detected! Connect your device and restart the application!")
        return None
    
    if devNum == 1:
        return Device.get_device(dev_list[0])
    
    choice = None
    if devNum > 1:
        print "Select the device to use for analysis:\n"
        for i in xrange(0, devNum):
            print "%d. %s\n" % ((i + 1), dev_list[i])
        
        while not choice:
            try:
                choice = int(raw_input())
                if choice not in range(1, devNum+1):
                    choice = None
                    print 'Invalid choice! Choose right number!'
            except ValueError:
                print 'Invalid Number! Choose right number!'
        
        
    return Device.get_device(dev_list[choice - 1])
开发者ID:tempbottle,项目名称:StaDynA,代码行数:29,代码来源:stadyna.py

示例2: init

def init( ):
    """ Initialise the device handle, boot to NAND flash.
        @returns: a device handle, i.e. a class Device instance.
    """

    print "  Initialising the device."
    print "  (Device will be powercycled in 60 secs if unresponsive)"
    power.power(1)
    t = threading.Timer( 60, powercycle )
    t.start()
    dev = Device( devtype = "hidav" )
    wait_networking( dev )    
    t.cancel()

    # set currently used partitions to the first partitions, 
    # so upgrade (detecting this) will use the other partitions
    dev.bootconfig = { "kernel" : 2, "rootfs" : 4 } 

    print "  Firmware version: %s" % dev.firmware_version
    print "  Boot config (current):"
    print "     Kernel:      /dev/mtd%s" % dev.bootconfig["kernel"]
    print "     rootfs: /dev/romblock%s" % dev.bootconfig["rootfs"]
    print "     epoch :             #%s" % dev.bootconfig["epoch"]

    print "  Booting into NAND..."
    dev.reboot( to_nand = True )
    wait_networking( dev )    
    return dev
开发者ID:erikb85,项目名称:HidaV,代码行数:28,代码来源:test-update_system.py

示例3: crawlDevice

def crawlDevice(ip_address,user,pw):
	sw1 = Device(ip=ip_address, username=user, password=pw)
	sw1.open()

	# Getting everything into dicts
	sh_vrf = get_vrf(sw1)
	int_brief = get_ip_int_b(sw1)
	int_status = get_int_status(sw1)
	hostname,proccesor_ID,version = get_hostname_serial_version(sw1)
	neighbors = get_cdp_info(sw1)
	port_channels = get_portchannel_sum(sw1)
	# Adding all data into objs
	LocalDevice = root_Device(hostname,proccesor_ID,version,ip_address,user,pw)

	for singleVrf in sh_vrf:
		vrf = Vrf(singleVrf["vrf-name-out"])
		if "TABLE_prefix" in singleVrf["TABLE_addrf"][ "ROW_addrf"].keys():
			for prefixes in singleVrf["TABLE_addrf"][ "ROW_addrf"]["TABLE_prefix"]["ROW_prefix"]:
				vrf.addPrefix(prefixes["ipprefix"])
			LocalDevice.addVrf(vrf)

	for ipInter in int_brief:
		LocalDevice.addIp(ipInter["ROW_intf"]["prefix"])

	LocalDevice.addPortChannel(port_channels)
	for interface in int_status:
		LocalDevice.addIp(interface)

	for neighbor in neighbors:
		neighEntry = Neighbors(root_Device,neighbor)
		LocalDevice.addNeighbor(neighEntry)



	return LocalDevice
开发者ID:knolls,项目名称:cisco_class,代码行数:35,代码来源:MultiAutoShark.py

示例4: main

def main():
    '''

    Main loop to retrieve data

    :return:
    '''
    args = getargs()

    username = args.user

    if not username:
        username = raw_input("Device Username:")

    password = getpass.getpass('Device password:')

    switch = Device(ip=args.switch, username=username, password=password)

    switch.open()

    result = get_forwardingpath(switch,
                                interface=args.interface,
                                src=args.source,
                                dst=args.destination,
                                lbalgo='ip' )

    print 'Traffic flowing from %s to %s will use physical interface %s' % (args.source, args.destination, result)
开发者ID:kevechol,项目名称:Kovarus-ACI-RP-Rotation,代码行数:27,代码来源:get-po-flow.py

示例5: active_device

def active_device(mac, ip='0.0.0.0', name='', time_stamp = datetime.datetime.now()):
    device_list = load_db()

    #time_stamp = datetime.datetime.now()

    mac_list = []
    for d in device_list:
        mac_list.append(d._mac)

    if not mac in mac_list:
        #have not found this device previously
        if len(name) < 1:
            #FIXME: should be more automated - no input should really be required
            name = input('What is the name of this machine? ('+ip+', '+mac+') ')

        from device import Device

        unkn_d = Device(name, mac)

        unkn_d.add_ip(ip)
        unkn_d.add_ts(time_stamp)

        #print("Adding new DEVICE to DB")
        device_list.append(unkn_d)

    else:
        # already part of the db - only add time stamp
        #print("Updating existing DEVICE in DB")

        index = mac_list.index(mac)
        device_list[index].add_ip(ip)
        device_list[index].add_ts(time_stamp)

    save_db(device_list)
开发者ID:C-Codes,项目名称:transmission-manager,代码行数:34,代码来源:knowledge.py

示例6: __init__

 def __init__(self, port, dimension=10, emulator=False):
     Device.__init__(self, "Cube", port)
     self.array = numpy.array([[\
             [0]*dimension]*dimension]*dimension, dtype='bool')
     self.dimension = dimension
     self.emulator = emulator
     self.name = "Cube"
开发者ID:MathewSam,项目名称:phosphene,代码行数:7,代码来源:cube.py

示例7: __init__

    def __init__(self, name):
        Device.__init__(self, name)
        self.ControlPanelClass = AudioTestGenControlPanel

        self.freqs = ObservableVariable([1000, 1000])
        self.freqs.changed.connect(self.change_freqs)

        caps = Gst.caps_from_string(self.SINGLE_CHANNEL_AUDIO_CAPS)

        self.src0 = Gst.ElementFactory.make('audiotestsrc', None)
        self.bin.add(self.src0)
        self.src0.set_property('is-live', True)

        self.src1 = Gst.ElementFactory.make('audiotestsrc', None)
        self.bin.add(self.src1)
        self.src1.set_property('is-live', True)

        self.interleave = Gst.ElementFactory.make('interleave', None)
        self.bin.add(self.interleave)

        self.src0.link_filtered(self.interleave, caps)
        self.src1.link_filtered(self.interleave, caps)

        self.add_output_audio_port_on(self.interleave, "src")

        self.change_freqs(self.freqs.get_value())
开发者ID:efirmaster,项目名称:open-playout,代码行数:26,代码来源:audio_test_gen.py

示例8: main

def main():
	'''Call the show_ip_int_brief function and read in from file'''
	
	#check they entered a filename
	if len(sys.argv) <= 1:
		print "You must enter a filename: int_brief.py <filename>"
		sys.exit()
	
	else:
		#check if the file name is correct and can be opened
		try:
			script, filename = sys.argv
			with open(filename, 'r') as fp:	#with will close file
				for line in fp:				#loop through the lines
					switch_admin = []
					if len(line.split()) == 3:	#check if there are three variables per line

						for word in line.split():	#loop through the words and add them to a list
							#fill a list with the items in the line - should be three
							switch_admin.append(word)
						
						#create the switch object
						switch = Device(ip=switch_admin[0], username=switch_admin[1], password=switch_admin[2])
						switch.open()
						#call the  function
						show_ip_int_brief(switch, switch_admin[0])
					else:
						print "Your file variables are incorrect. It should be <ip address> <username> <password> per line."
						sys.exit()
		except IOError:
			print "Your file was mistyped! Please try again."
			sys.exit()
开发者ID:lisroach,项目名称:9k_scripts,代码行数:32,代码来源:int_brief.py

示例9: __init__

    def __init__(self, width, height, fullscreen):
        print "glut::__init__()"
        Device.__init__(self)

        self.size = (width, height)
        self.fullscreen = fullscreen

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)

        if self.fullscreen:
            glutGameModeString("%dx%d:[email protected]" % self.size )
            self.windowID = glutEnterGameMode()
        else:
            glutInitWindowSize(self.size[0], self.size[1])
            glutInitWindowPosition(0,0)
            self.windowID = glutCreateWindow("")

        glutSetWindow(self.windowID)

        glutReshapeFunc(self.reSizeGLScene)
        glutMouseFunc(self.onMouse)
        glutMotionFunc(self.onMotion)
        glutPassiveMotionFunc(self.onMotion)
        glutKeyboardFunc(self.onKeyDown)
        glutKeyboardUpFunc(self.onKeyUp)
        glutSpecialFunc(self.onSpecialDown)
        glutSpecialUpFunc(self.onSpecialUp)

        self.graphicsDevice = OpenGLGraphics(self.size)
开发者ID:Ripsnorta,项目名称:pyui2,代码行数:30,代码来源:glutdevice.py

示例10: observed_devices

 def observed_devices(self, user_id):
     dev_ids = self.find_by('where user_id = ?', user_id)
     devices = []
     dev = Device()
     for dev_id in dev_ids:
         devices.append(dev.get(dev_id.device_id))
     return devices
开发者ID:hazelor,项目名称:COO_new,代码行数:7,代码来源:device_observed.py

示例11: __init__

    def __init__(self, name):
        Device.__init__(self, name)
        self.ControlPanelClass = DskControlPanel

        self.file = ObservableVariable()
        self.file.changed.connect(self.file_changed)

        self.alpha = ObservableVariable(0)
        self.alpha.changed.connect(self.alpha_changed)

        # While input convert doesn't seem explicitly necessary, it seems to
        # give better performance.  Not sure why.
        self.inputconvert = self.add_element('videoconvert')
        self.mixer = self.add_element('videomixer')
        self.outputconvert = self.add_element('videoconvert')

        self.add_input_video_port_on(self.inputconvert)
        self.inputconvert.link(self.mixer)

        self.mixer.link(self.outputconvert)
        self.add_output_video_port_on(self.outputconvert)

        self.mixer.get_static_pad('sink_0').set_property('zorder', 0)

        self.alpha.set_value(1.0)
开发者ID:efirmaster,项目名称:open-playout,代码行数:25,代码来源:dsk.py

示例12: callModule

 def callModule(self, modulename, board_number, number, function, params = []):
     """
     Call one function: function for module: modulename in board: board_name
     with handler: number (only if the module is pnp, else, the parameter is
     None) with parameteres: params
     """
     try:
         board = self._bb[board_number]
         if board.devices.has_key(number) and (board.devices[number].name == modulename):
             return board.devices[number].call_function(function, params)
         else:
             if modulename in self._openables:
                 if modulename in board.get_openables_loaded():
                     number = board.get_device_handler(modulename)
                 else:
                     board.add_openable_loaded(modulename)
                     dev = Device(board, modulename)
                     number = dev.module_open()
                     dev.add_functions(self._drivers_loaded[modulename])
                     board.add_device(number, dev)
                 return board.devices[number].call_function(function, params)
             else:
                 if self._debug:
                     print 'no open and no openable'
                 return ERROR
     except Exception, err:
         if self._debug:
             print 'error call module', err
         return ERROR
开发者ID:nfurquez,项目名称:LabRobEmb2013,代码行数:29,代码来源:usb4butia.py

示例13: __init__

 def __init__(self, name, major=None, minor=None, exists=None,
              format=None, parents=None, sysfsPath='', vendor="",
              model=""):
     Device.__init__(self, name, format=format,
                     major=major, minor=minor, exists=True,
                     parents=parents, sysfsPath=sysfsPath,
                     vendor=vendor, model=model)
开发者ID:MusaSakizci,项目名称:yali-family,代码行数:7,代码来源:opticaldevice.py

示例14: __init__

    def __init__(self, width, height, fullscreen, mode=P2D):
        Device.__init__(self)

        self.mode = mode
        self.size = (width, height)

        pygame.init()
        pygame.key.set_mods(KMOD_NONE)
        pygame.mouse.set_visible(0)

        if mode == PygameDevice.P2D:
            flags = 0
            if fullscreen:
                flags = flags | pygame.locals.FULLSCREEN | pygame.locals.SWSURFACE

            self.graphicsDevice = PygameGraphics(self.size, flags)

        elif mode == PygameDevice.OGL:
            from openglgraphics import OpenGLGraphics
            
            flags = pygame.locals.OPENGL | pygame.locals.DOUBLEBUF
            if fullscreen:
                flags = flags | pygame.locals.FULLSCREEN

            self.graphicsDevice = OpenGLGraphics(self.size, flags, pygame.display.set_mode(self.size, flags))

        else:
            raise device.DeviceException("Invalid Graphics Mode Specified")
开发者ID:Ripsnorta,项目名称:pyui2,代码行数:28,代码来源:pygamedevice.py

示例15: DeviceTest

class DeviceTest(unittest.TestCase):
    def setUp(self):
        self.block_size = 1
        self.blocks = 100
        self.dev = Device("data", self.block_size, self.blocks)
        self.data = [randrange(0, 256) for i in range(0, self.blocks)]
        for i, block in enumerate(self.data):
            self.dev.write_block(i, chr(block))

    def test_memory_read(self):
        self.should_preserve_data(self.dev)

    def test_file_read(self):
        self.dev.close()
        dev = Device("data", self.block_size, self.blocks)
        self.should_preserve_data(dev)

    def should_preserve_data(self, dev):
        for i, block in enumerate(self.data):
            read = dev.read_block(i)
            self.assertEqual(read, chr(block))

    @unittest.expectedFailure
    def test_fail_to_write_data_bigger_than_block(self):
        self.dev.write_block(0, b'aa')

    @unittest.expectedFailure
    def test_fail_with_out_of_bounds(self):
        self.dev.write_block(self.blocks + 1, b'a')

    def tearDown(self):
        self.dev.close()
开发者ID:rtshadow,项目名称:miscs,代码行数:32,代码来源:device_test.py


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