示例#1
0
def set_auth_cache_filepath(auth_storage_filepath):
    Conf.set('auth_cache_filepath', auth_storage_filepath)
示例#2
0
#!/usr/bin/env python2.7

import sys
sys.path.insert(0, '..')

import datetime
import time
import dateutil.tz

from gdrivefs.conf import Conf
Conf.set('auth_cache_filepath', '/var/cache/creds/gdfs')

import gdrivefs.gdfs.gdfuse
import gdrivefs.gdtool.drive
import gdrivefs.time_support

auth = gdrivefs.gdtool.drive.GdriveAuth()
client = auth.get_client()

def get_phrase(epoch):
    dt = datetime.datetime.utcfromtimestamp(entry.modified_date_epoch)
    return datetime.datetime.strftime(dt, gdrivefs.time_support.DTF_DATETIMET)

print("Before:\n")

(entry, path, filename) = gdrivefs.gdfs.gdfuse.get_entry_or_raise(
                            '/20140426-171136')

print(entry.modified_date)
print(entry.modified_date.utctimetuple())
print(entry.modified_date_epoch)
示例#3
0
def mount(auth_storage_filepath, mountpoint, debug=None, nothreads=None, 
          option_string=None):

    fuse_opts = { }
    if option_string:
        for opt_parts in [opt.split('=', 1) \
                          for opt \
                          in option_string.split(',') ]:
            k = opt_parts[0]

            # We need to present a bool type for on/off flags. Since all we
            # have are strings, we'll convert anything with a 'True' or 'False'
            # to a bool, or anything with just a key to True.
            if len(opt_parts) == 2:
                v = opt_parts[1]
                v_lower = v.lower()

                if v_lower == 'true':
                    v = True
                elif v_lower == 'false':
                    v = False
            else:
                v = True

            # We have a list of provided options. See which match against our 
            # application options.

            logging.info("Setting option [%s] to [%s]." % (k, v))

            try:
                Conf.set(k, v)
            except (KeyError) as e:
                logging.debug("Forwarding option [%s] with value [%s] to "
                              "FUSE." % (k, v))

                fuse_opts[k] = v
            except:
                logging.exception("Could not set option [%s]. It is probably "
                                  "invalid." % (k))
                raise

    logging.debug("PERMS: F=%s E=%s NE=%s" % 
                  (Conf.get('default_perm_folder'), 
                   Conf.get('default_perm_file_editable'), 
                   Conf.get('default_perm_file_noneditable')))

    # Assume that any option that wasn't an application option is a FUSE 
    # option. The Python-FUSE interface that we're using is beautiful/elegant,
    # but there's no help support. The user is just going to have to know the
    # options.

    set_auth_cache_filepath(auth_storage_filepath)

    # How we'll appear in diskfree, mtab, etc..
    name = ("gdfs(%s)" % (auth_storage_filepath))

    # Don't start any of the scheduled tasks, such as change checking, cache
    # cleaning, etc. It will minimize outside influence of the logs and state
    # to make it easier to debug.

#    atexit.register(Timers.get_instance().cancel_all)
    if debug:
        Timers.get_instance().set_autostart_default(False)

    fuse = FUSE(GDriveFS(), mountpoint, debug=debug, foreground=debug, 
                nothreads=nothreads, fsname=name, **fuse_opts)
示例#4
0
文件: gdfuse.py 项目: He1my/GDriveFS
def set_auth_cache_filepath(auth_storage_filepath):
    Conf.set('auth_cache_filepath', auth_storage_filepath)
示例#5
0
文件: gdfuse.py 项目: He1my/GDriveFS
def mount(auth_storage_filepath,
          mountpoint,
          debug=None,
          nothreads=None,
          option_string=None):

    fuse_opts = {}
    if option_string:
        for opt_parts in [opt.split('=', 1) \
                          for opt \
                          in option_string.split(',') ]:
            k = opt_parts[0]

            # We need to present a bool type for on/off flags. Since all we
            # have are strings, we'll convert anything with a 'True' or 'False'
            # to a bool, or anything with just a key to True.
            if len(opt_parts) == 2:
                v = opt_parts[1]
                v_lower = v.lower()

                if v_lower == 'true':
                    v = True
                elif v_lower == 'false':
                    v = False
            else:
                v = True

            # We have a list of provided options. See which match against our
            # application options.

            logging.info("Setting option [%s] to [%s]." % (k, v))

            try:
                Conf.set(k, v)
            except (KeyError) as e:
                logging.debug("Forwarding option [%s] with value [%s] to "
                              "FUSE." % (k, v))

                fuse_opts[k] = v
            except:
                logging.exception("Could not set option [%s]. It is probably "
                                  "invalid." % (k))
                raise

    logging.debug("PERMS: F=%s E=%s NE=%s" %
                  (Conf.get('default_perm_folder'),
                   Conf.get('default_perm_file_editable'),
                   Conf.get('default_perm_file_noneditable')))

    # Assume that any option that wasn't an application option is a FUSE
    # option. The Python-FUSE interface that we're using is beautiful/elegant,
    # but there's no help support. The user is just going to have to know the
    # options.

    set_auth_cache_filepath(auth_storage_filepath)

    # How we'll appear in diskfree, mtab, etc..
    name = ("gdfs(%s)" % (auth_storage_filepath))

    # Don't start any of the scheduled tasks, such as change checking, cache
    # cleaning, etc. It will minimize outside influence of the logs and state
    # to make it easier to debug.

    #    atexit.register(Timers.get_instance().cancel_all)
    if debug:
        Timers.get_instance().set_autostart_default(False)

    fuse = FUSE(GDriveFS(),
                mountpoint,
                debug=debug,
                foreground=debug,
                nothreads=nothreads,
                fsname=name,
                **fuse_opts)
示例#6
0
def set_auth_cache_filepath(auth_storage_filepath):
    auth_storage_filepath = os.path.abspath(auth_storage_filepath)

    Conf.set('auth_cache_filepath', auth_storage_filepath)
示例#7
0
def mount(auth_storage_filepath, mountpoint, debug=None, nothreads=None, 
          option_string=None):

    if os.path.exists(auth_storage_filepath) is False:
        raise ValueError("Credential path is not valid: [%s]" %
                         (auth_storage_filepath,))

    # If we don't check this here, it'll just cause a headache when things fail
    # during the communication.
    oauth2_version = tuple([int(c) for c in oauth2client.__version__.split('.')])
    if oauth2_version >= (4, 0, 0):
        raise Exception("Google does not like oauth2client >=4.0.0 .")

    fuse_opts = {}
    
    if option_string:
        for opt_parts in [opt.split('=', 1) \
                          for opt \
                          in option_string.split(',') ]:
            k = opt_parts[0]

            # We need to present a bool type for on/off flags. Since all we
            # have are strings, we'll convert anything with a 'True' or 'False'
            # to a bool, or anything with just a key to True.
            if len(opt_parts) == 2:
                v = opt_parts[1]
                v_lower = v.lower()

                if v_lower == 'true':
                    v = True
                elif v_lower == 'false':
                    v = False
            else:
                v = True

            # We have a list of provided options. See which match against our 
            # application options.

            _logger.debug("Setting option [%s] to [%s].", k, v)

            try:
                Conf.set(k, v)
            except KeyError as e:
                _logger.debug("Forwarding option [%s] with value [%s] to "
                              "FUSE.", k, v)

                fuse_opts[k] = v

    if gdrivefs.config.IS_DEBUG is True:
        _logger.debug("FUSE options:\n%s", pprint.pformat(fuse_opts))

    _logger.debug("PERMS: F=%s E=%s NE=%s",
                  Conf.get('default_perm_folder'), 
                  Conf.get('default_perm_file_editable'), 
                  Conf.get('default_perm_file_noneditable'))

    # Assume that any option that wasn't an application option is a FUSE 
    # option. The Python-FUSE interface that we're using is beautiful/elegant,
    # but there's no help support. The user is just going to have to know the
    # options.

    set_auth_cache_filepath(auth_storage_filepath)

    # How we'll appear in diskfree, mtab, etc..
    name = "gdfs(%s)".format(auth_storage_filepath)

    # Make sure we can connect.
    gdrivefs.account_info.AccountInfo().get_data()
    gdfs = GDriveFS()

    fuse = FUSE(
            gdfs,
            mountpoint, 
            debug=debug, 
            foreground=debug, 
            nothreads=nothreads, 
            fsname=name, 
            **fuse_opts)
示例#8
0
def mount(auth_storage_filepath, mountpoint, debug=None, nothreads=None, option_string=None):

    if os.path.exists(auth_storage_filepath) is False:
        raise ValueError("Credential path is not valid: [%s]" % (auth_storage_filepath,))

    fuse_opts = {}

    if option_string:
        for opt_parts in [opt.split("=", 1) for opt in option_string.split(",")]:
            k = opt_parts[0]

            # We need to present a bool type for on/off flags. Since all we
            # have are strings, we'll convert anything with a 'True' or 'False'
            # to a bool, or anything with just a key to True.
            if len(opt_parts) == 2:
                v = opt_parts[1]
                v_lower = v.lower()

                if v_lower == "true":
                    v = True
                elif v_lower == "false":
                    v = False
            else:
                v = True

            # We have a list of provided options. See which match against our
            # application options.

            _logger.debug("Setting option [%s] to [%s].", k, v)

            try:
                Conf.set(k, v)
            except (KeyError) as e:
                _logger.debug("Forwarding option [%s] with value [%s] to " "FUSE.", k, v)

                fuse_opts[k] = v
            except:
                _logger.exception("Could not set option [%s]. It is probably " "invalid.", k)
                raise

    if gdrivefs.config.IS_DEBUG is True:
        _logger.debug("FUSE options:\n%s", pprint.pformat(fuse_opts))

    _logger.debug(
        "PERMS: F=%s E=%s NE=%s",
        Conf.get("default_perm_folder"),
        Conf.get("default_perm_file_editable"),
        Conf.get("default_perm_file_noneditable"),
    )

    # Assume that any option that wasn't an application option is a FUSE
    # option. The Python-FUSE interface that we're using is beautiful/elegant,
    # but there's no help support. The user is just going to have to know the
    # options.

    set_auth_cache_filepath(auth_storage_filepath)

    # How we'll appear in diskfree, mtab, etc..
    name = "gdfs(%s)" % (auth_storage_filepath,)

    # Make sure we can connect.
    gdrivefs.gdtool.account_info.AccountInfo().get_data()

    fuse = FUSE(GDriveFS(), mountpoint, debug=debug, foreground=debug, nothreads=nothreads, fsname=name, **fuse_opts)