コード例 #1
0
ファイル: dev.py プロジェクト: DawnSG/quantumrandom
def main():
    num_threads = 3
    if '-h' in sys.argv:
        raise SystemExit('Usage: %s [-v] [-t THREADS]')
    if '-t' in sys.argv:
        num_threads = int(sys.argv[sys.argv.index('-t') + 1])
    if '-v' not in sys.argv:
        global log
        def noop(msg): pass
        log = noop

    operations = QuantumRandomDevice(num_threads)
    cuse.init(operations, 'qrandom', [])

    try:
        cuse.main(True)
    except Exception, err:
        log("CUSE main ended %s" % str(err))
コード例 #2
0
ファイル: dev.py プロジェクト: nseidm1/1inchpython
def main():
    num_threads = 3
    if '-h' in sys.argv:
        raise SystemExit('Usage: %s [-v] [-t THREADS]')
    if '-t' in sys.argv:
        num_threads = int(sys.argv[sys.argv.index('-t') + 1])
    if '-v' not in sys.argv:
        global log
        def noop(msg): pass
        log = noop

    operations = QuantumRandomDevice(num_threads)
    cuse.init(operations, 'qrandom', [])

    try:
        cuse.main(True)
    except:
        log(traceback.format_exc())
        log("CUSE main ended")
コード例 #3
0
ファイル: cuse_example.py プロジェクト: sugarmanz/cusepy
    self.input_buffer+=buf[offset:length]
    print (self.input_buffer)
    libcuse.fuse_reply_write(req, length)

  def read(self, req, size, off, file_info):
    out = self.input_buffer[off:size]
    print ("read size: %s off: %s reply: %s buffer: %s" % (
      size, off, len(out), len(self.input_buffer)))
    libcuse.fuse_reply_buf(req, self.input_buffer[off:size], len(out))
    self.input_buffer=self.input_buffer[off+size+1:]

  def ioctl(self, req, cmd, arg_p, file_info, uflags, in_buff_p,
							in_bufsz, out_bufsz):
    print ("ioctl %s" % ioctl_dict[cmd])
    libcuse.fuse_reply_ioctl(req, 0, None, 0);


if __name__ == '__main__':
    
    if len(sys.argv) < 2:
        raise SystemExit('Usage: %s <devname>' % sys.argv[0])
    
    devname = sys.argv[1]
    operations = Device()
    
    cuse.init(operations, devname, sys.argv[2:])
    try:
	cuse.main(True)
    except Exception, err:
	print ("CUSE main ended %s" % str(err))