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


Python drive.Drive类代码示例

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


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

示例1: __init__

 def __init__(self,mode,device,calibrationSpeeds):
     baud = 9600
     if mode == Mode.SIM:
         self.drive = Drive(device,baud,simulate=1,calibration=calibrationSpeeds)
     elif mode == Mode.LIVE:
         self.drive = Drive(device,baud,simulate=0,calibration=calibrationSpeeds, persist=False)
     self.pos = self.azalt()
     self.getCurrentPos()
     self.location = self.drive.location  #TODO - use this
     self.status = Status.INIT
     self.mode = mode
开发者ID:acrerd,项目名称:acreroad_1420,代码行数:11,代码来源:srt.py

示例2: __init__

 def __init__(self):
     super().__init__()
     self.loader = Loader()
     self.shooter = Shooter()
     self.drive = Drive(config.robotDrive, config.leftJoy, config.hsButton,
                        config.alignButton)
     self.componets = [ self.loader, self.shooter, self.drive ]
开发者ID:HappyFox,项目名称:2012_basket_ball_robot,代码行数:7,代码来源:robot.py

示例3: mount

    def mount(drive_name):
        '''
        Reconnects a drive as a volume.
        Any data on the drive is preserved.
        Returns the volume.
        '''
        drive = Drive.reconnect(drive_name)
        vol = Volume()

        block = drive.read_block(0).split(b'\n')
        volinfosize= int(bytes.decode(block[0]))
        volinfo =b''
        volinfo+=drive.read_block(0)
        if volinfosize!=1:
            for i in range (1,volinfosize+1):
                volinfo+=drive.read_block(i)
        vol.setSize(int(bytes.decode(block[2])))
        vol.setDrive(drive)

        bmpArr =[]
        
        bmp = bytes.decode(volinfo.split(b'\n')[3])

        for i,v in enumerate(bmp):
            if v == 'x':
                bmpArr.append(1)
            else:
                bmpArr.append(0)
        vol.setVolInfo(volinfo)
        vol.setBitmapArray(bmpArr)
        return vol
开发者ID:raouldc,项目名称:File-System,代码行数:31,代码来源:filesystem.py

示例4: mount

	def mount(drive_name):
		'''
		Reconnects a drive as a volume.
		Any data on the drive is preserved.
		Returns the volume.
		'''
		drive = Drive.reconnect(drive_name)
		inputt = drive.read_block(0)
		data = inputt.splitlines()
		length = int(data[0])
		i = 1
		while i < length:
			inputt = drive.read_block(i)
			data.extend(inputt.splitlines())
			i+=1
		i = 1
		outcome = False
		
		data[len(data)-1] = data[len(data)-1].rstrip()
	
		while len(data) > (i+1):
			while len(data) > (i+1) and data[i+1].isdigit() == outcome:
				data[i] += data[i+1]
				data.pop(i+1)
			i+=1
			outcome = not outcome
		
		volume = Volume(drive, data[1])
		for i in range(len(data[3])):                #TODO Needs better fix
			if data[3][i] == 120:
				volume.bmap[i] = b'x'
		volume.import_files()

		return volume
开发者ID:Dahaden,项目名称:370a2,代码行数:34,代码来源:filesystem.py

示例5: Upload

class Upload(object):
    """
    TODO interface or abstract class for upload services
    """

    def __init__(self, config, service_type):
        self.__config = config
        if service_type == SERVICE_DRIVE:
            self.service = Drive(config)
        elif service_type == SERVICE_DROPBOX:
            raise NotImplementedError('not implemented yet!')

    def run(self, paths):
        """
        """
        for path in paths:
            self.service.upload(path)
            log_dict(self.service.info)
开发者ID:Diwahars,项目名称:Sample,代码行数:18,代码来源:upload.py

示例6: __init__

 def __init__(self, config, service_type):
     self.__config = config
     self.info = {
         'details': []
     }
     if service_type == SERVICE_DRIVE:
         self.service = Drive(config)
     elif service_type == SERVICE_DROPBOX:
         raise NotImplementedError('not implemented yet!')
开发者ID:devnuhl,项目名称:packtpub-crawler,代码行数:9,代码来源:upload.py

示例7: test_long_volume_name

 def test_long_volume_name(self):
     blocks = 100
     drive_name = 'driveH.txt'
     disk = Drive.format(drive_name, blocks)
     name = b'long volume name' * 100
     volume = Volume.format(disk, name)
     self.assertEqual(name, volume.name())
     self.assertEqual(blocks, volume.size())
     self.assertEqual(99, volume.root_index())
     volume.unmount()
开发者ID:1and1get2,项目名称:cs340ass2,代码行数:10,代码来源:modifiedfilesystemtest.py

示例8: mount

    def mount(drive_name):
        drive = Drive.reconnect(drive_name)
        allVolumeData = drive.read_block(0).decode()
        numOfBlocksUsed = allVolumeData.split('\n',1)[0]
        if int(numOfBlocksUsed)>1:
            for i in range(1,int(numOfBlocksUsed)):
                allVolumeData+=drive.read_block(i).decode() 
                
        data = allVolumeData.split('\n')
        numOfBlocksUsed=int(data[0])
        name = data[1]
        #dont need this
        numOfBlocksInDrive = int(data[2])
        bitmap = data[3]
        rootIndex = int(data[4])
        usedDrives=[False]*numOfBlocksInDrive
        Volume.calculate_volume_data_blocks(name, drive, rootIndex)
        numOfDataBlocks = Volume.calculate_volume_data_blocks(name, drive, rootIndex )
        for i in range(numOfDataBlocks):
            usedDrives[i]=True
        usedDrives[rootIndex]=True
        volume = Volume(drive, name.encode(), rootIndex, usedDrives, numOfBlocksUsed)
        #read the rootdirectory
        rootString = drive.read_block(rootIndex).decode()
        root= rootString.split('\n')
        for i in range(len(root)):
            if root[i].isdigit():
                if int(root[i])!=0:

                    fileData =  volume.drive.read_block(int(root[i])).decode().split('\n')
                    for i in range(0,len(fileData)-1,3):
                        fileName = fileData[i]
                        fileDataLength =  fileData[i+1]
                        fileStart = fileData[i + 2]
                        #then go into the fileStart
                        fileDirectory = volume.drive.read_block(int(fileStart))
                        fileDirectory = fileDirectory.decode().split('\n')
                        dataLocations = []
                        for j in range(len(fileDirectory)):
                            if fileDirectory[j].isdigit():
                                dataLocations.append(fileDirectory[j])
                        #now that we have all the locations of the data, we can read all the locations and concatinate them
                        dataOnFile = b''
                        for k in range(len(dataLocations)):
                            dataOnFile+=volume.drive.read_block(int(dataLocations[k]))
                        #only want the first n bits
                        dataOnFile = dataOnFile[:int(fileDataLength)]    
                        file = volume.open(fileName.encode())
                        file.write(0, dataOnFile)
                        print (file.data)
                    
        #print (root)
        
        return volume
        '''
开发者ID:qisaw,项目名称:se370_Assignment_2,代码行数:55,代码来源:filesystem.py

示例9: test_reconnect_drive

 def test_reconnect_drive(self):
      blocks = 10
      drive_name = 'driveC.txt'
      drive = Drive.format(drive_name, blocks)
      drive.disconnect()
      with self.assertRaises(IOError):
          Drive.reconnect('badname')
      drive = Drive.reconnect(drive_name)
      self.assertEqual(blocks * Drive.BLK_SIZE, drive.num_bytes())
      name = b'reconnect volume'
      volume = Volume.format(drive, name)
      volume.unmount()
      with self.assertRaises(IOError):
          Volume.mount('driveZ')
      volume = Volume.mount(drive_name)
      self.assertEqual(1, volume.volume_data_blocks())
      self.assertEqual(name, volume.name())
      self.assertEqual(blocks, volume.size())
      self.assertEqual(b'x--------x', volume.bitmap())
      self.assertEqual(9, volume.root_index())
      volume.unmount()
开发者ID:raouldc,项目名称:File-System,代码行数:21,代码来源:filesystemtest.py

示例10: test_long_volume_name

 def test_long_volume_name(self):
      blocks = 10
      drive_name = 'driveB.txt'
      drive = Drive.format(drive_name, blocks)
      name = b'long volume name' * 10
      volume = Volume.format(drive, name)
      self.assertEqual(3, volume.volume_data_blocks())
      self.assertEqual(name, volume.name())
      self.assertEqual(blocks, volume.size())
      self.assertEqual(b'xxx------x', volume.bitmap())
      self.assertEqual(9, volume.root_index())
      volume.unmount()
开发者ID:raouldc,项目名称:File-System,代码行数:12,代码来源:filesystemtest.py

示例11: test_file_reads

 def test_file_reads(self):
      volume = Volume.format(Drive.format('driveE.txt', 8), b'file read volume')
      file = volume.open(b'fileA')
      data = b'A different fileA'
      file.write(0, data)
      with self.assertRaises(IOError):
          file.read(30, 1)
      with self.assertRaises(IOError):
          file.read(0, 50)
      self.assertEqual(data, file.read(0, len(data)))
      self.assertEqual(b'if', file.read(3, 2))
      file.write(file.size(), b'Aaargh' * 10)
      self.assertEqual(b'arghAaarghAaargh', file.read(61, 16))
      volume.unmount()
开发者ID:raouldc,项目名称:File-System,代码行数:14,代码来源:filesystemtest.py

示例12: test_file_reads

 def test_file_reads(self):
     volume = Volume.format(Drive.format("driveK.txt", 100), b'file read volume')
     file = volume.open(b'fileA')
     data = b'A different fileA' * 10
     file.write(0, data)
     with self.assertRaises(IOError):
         file.read(300, 1)
     with self.assertRaises(IOError):
         file.read(0, 500)
     self.assertEqual(data, file.read(0, len(data)))
     self.assertEqual(b'if', file.read(71, 2))
     file.write(file.size(), b'Aaargh' * 100)
     self.assertEqual(b'AaarghAaargh', file.read(500, 12))
     volume.unmount()
开发者ID:1and1get2,项目名称:cs340ass2,代码行数:14,代码来源:modifiedfilesystemtest.py

示例13: test_reconnect_drive_with_files

 def test_reconnect_drive_with_files(self):
     drive_name = 'driveF.txt'
     volume = Volume.format(Drive.format(drive_name, 12), b'reconnect with files volume')
     filenames = [b'file1', b'file2', b'file3', b'file4']
     files = [volume.open(name) for name in filenames]
     for i, file in enumerate(files):
         file.write(0, bytes(str(i).encode()) * 64)
     files[0].write(files[0].size(), b'a')
     volume.unmount()
     volume = Volume.mount(drive_name)
     file4 = volume.open(b'file4')
     self.assertEqual(b'3333', file4.read(0, 4))
     file1 = volume.open(b'file1')
     self.assertEqual(65, file1.size())
     self.assertEqual(b'0a', file1.read(63, 2))
     volume.unmount()
开发者ID:1and1get2,项目名称:cs340ass2,代码行数:16,代码来源:filesystemtest.py

示例14: test_simple_file_creation

 def test_simple_file_creation(self):
     # the Volume didn't call format in the original
     volume = Volume.format(Drive.format('driveD.txt', 8), b'file creation volume')
     with self.assertRaises(ValueError):
      volume.open(b'fileA\n')
     file = volume.open(b'fileA')
     self.assertEqual(0, file.size())
     data = b'Hello from fileA'
     file.write(0, data)
     self.assertEqual(len(data), file.size())
     file.write(file.size(), data)
     self.assertEqual(2 * len(data), file.size())
     file = volume.open(b'fileB')
     data = b'Welcome to fileB'
     file.write(50, data)
     self.assertEqual(50 + len(data), file.size())
     volume.unmount()
开发者ID:raouldc,项目名称:File-System,代码行数:17,代码来源:filesystemtest.py

示例15: test_new_volume

 def test_new_volume(self):
     blocks = 10
     drive_name = 'driveA.txt'
     drive = Drive.format(drive_name, blocks)
     with self.assertRaises(ValueError):
         Volume.format(drive, b'')
     with self.assertRaises(ValueError):
         Volume.format(drive, b'Volume\nA')
     with self.assertRaises(ValueError):
         Volume.format(drive, b'a' * blocks * Drive.BLK_SIZE)
     name = b'new volume test'
     volume = Volume.format(drive, name)
     self.assertEqual(1, volume.volume_data_blocks())
     self.assertEqual(name, volume.name())
     self.assertEqual(blocks, volume.size())
     self.assertEqual(b'x--------x', volume.bitmap())
     self.assertEqual(9, volume.root_index())
     volume.unmount()
开发者ID:raouldc,项目名称:File-System,代码行数:18,代码来源:filesystemtest.py


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