예제 #1
0
class DriveFuse(fuse.Fuse):
    def __init__(self, email, *args, **kw):
        super(DriveFuse, self).__init__(*args, **kw)
        self.drive_service = DriveService(email)
        self.codec = 'utf-8'

    # mknod, write, flush, unlink, mkdir, rmdir, rename, truncate
    def getattr(self, path):
        f = self.drive_service.lookup(unicode(path, self.codec))
        if f is None:
            return -errno.ENOENT

        st = fuse.Stat()
        if f.is_folder():
            st.st_mode = stat.S_IFDIR | 0744
            st.st_nlink = 1 + len(f.parents)
        else:
            st.st_mode = stat.S_IFREG | 0744
            st.st_nlink = len(f.parents)
        st.st_size = f.get_file_size()
        st.st_ino = 0
        st.st_dev = 0
        st.st_uid = os.getuid()
        st.st_gid = os.getgid()
        st.st_atime = f.get_access_date()
        st.st_mtime = f.get_modify_date()
        st.st_ctime = f.get_create_date()

        return st

    def readdir(self, path, offset):
        folder = self.drive_service.lookup(unicode(path, self.codec))
        if folder is None:
            yield -errno.ENOENT
        dirents = self.drive_service.readdir(folder)
        dirnames = [e.escaped_name for e in dirents]
        dirnames.extend([".", ".."])
        for n in dirnames:
            yield fuse.Direntry(n.encode(self.codec))

    def open(self, path, flags):
        pass

    def read(self, path, size=-1, offset=0, fh=None):
        pass

    def release(self, path, flags, fh=None):
        pass
예제 #2
0
class DriveFuse(fuse.Fuse):
    def __init__(self, email, *args, **kw):
        super(DriveFuse, self).__init__(*args, **kw)
        self.drive_service = DriveService(email)
        self.codec = 'utf-8'

    # mknod, write, flush, unlink, mkdir, rmdir, rename, truncate
    def getattr(self, path):
        f = self.drive_service.lookup(unicode(path, self.codec))
        if f is None:
            return -errno.ENOENT

        st = fuse.Stat()
        if f.is_folder():
            st.st_mode = stat.S_IFDIR | 0744
            st.st_nlink = 1 + len(f.parents)
        else:
            st.st_mode = stat.S_IFREG | 0744
            st.st_nlink = len(f.parents)
        st.st_size = f.get_file_size()
        st.st_ino = 0
        st.st_dev = 0
        st.st_uid = os.getuid()
        st.st_gid = os.getgid()
        st.st_atime = f.get_access_date()
        st.st_mtime = f.get_modify_date()
        st.st_ctime = f.get_create_date()

        return st

    def readdir(self, path, offset):
        folder = self.drive_service.lookup(unicode(path, self.codec))
        if folder is None:
            yield -errno.ENOENT
        dirents = self.drive_service.readdir(folder)
        dirnames = [e.escaped_name for e in dirents]
        dirnames.extend([".", ".."])
        for n in dirnames:
            yield fuse.Direntry(n.encode(self.codec))

    def open(self, path, flags):
        pass
    def read(self, path, size = -1, offset = 0, fh = None):
        pass
    def release(self, path, flags, fh = None):
        pass
예제 #3
0
 def __init__(self, email, *args, **kw):
     super(DriveFuse, self).__init__(*args, **kw)
     self.drive_service = DriveService(email)
     self.codec = 'utf-8'
예제 #4
0
 def __init__(self, email, *args, **kw):
     super(DriveFuse, self).__init__(*args, **kw)
     self.drive_service = DriveService(email)
     self.codec = 'utf-8'
예제 #5
0
humidity_svc = HumidityService()
humidity_svc.measurement_period = 100
humidity_last_update = 0

light_svc = LightSensorService()
light_svc.measurement_period = 100
light_last_update = 0

temp_svc = TemperatureService()
temp_svc.measurement_period = 100
temp_last_update = 0

tone_svc = ToneService()

drive_svc = DriveService()
kit = ServoKit(channels=16)

exploration_svc = ExplorationService()

ble = BLERadio()
# The Web Bluetooth dashboard identifies known boards by their
# advertised name, not by advertising manufacturer data.
ble.name = "CLUE"

# The Bluefruit Playground app looks in the manufacturer data
# in the advertisement. That data uses the USB PID as a unique ID.
# Adafruit CLUE USB PID:
# Arduino: 0x8071,  CircuitPython: 0x8072, app supports either
adv = AdafruitServerAdvertisement()
adv.pid = 0x8072