本文整理汇总了Python中gdrivefs.conf.Conf.set方法的典型用法代码示例。如果您正苦于以下问题:Python Conf.set方法的具体用法?Python Conf.set怎么用?Python Conf.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdrivefs.conf.Conf
的用法示例。
在下文中一共展示了Conf.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_auth_cache_filepath
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
def set_auth_cache_filepath(auth_storage_filepath):
Conf.set('auth_cache_filepath', auth_storage_filepath)
示例2: mount
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
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)
示例3: get_phrase
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
#!/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)
示例4: set_auth_cache_filepath
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
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)
示例5: mount
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
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)
示例6: mount
# 需要导入模块: from gdrivefs.conf import Conf [as 别名]
# 或者: from gdrivefs.conf.Conf import set [as 别名]
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)