本文整理汇总了Python中twisted.python.filepath.FilePath.decode方法的典型用法代码示例。如果您正苦于以下问题:Python FilePath.decode方法的具体用法?Python FilePath.decode怎么用?Python FilePath.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.filepath.FilePath
的用法示例。
在下文中一共展示了FilePath.decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _finish_convergence_service
# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import decode [as 别名]
def _finish_convergence_service(
k8s_client, options, subscription_client, reactor,
):
k8s = KubeClient(k8s=k8s_client)
access_key_id = FilePath(options["aws-access-key-id-path"]).getContent().strip()
secret_access_key = FilePath(options["aws-secret-access-key-path"]).getContent().strip()
aws = AWSServiceRegion(creds=AWSCredentials(
access_key=access_key_id,
secret_key=secret_access_key,
))
Message.log(
event=u"convergence-service:key-notification",
key_id=access_key_id.decode("ascii"),
secret_key_hash=sha256(secret_access_key).hexdigest().decode("ascii"),
)
config = DeploymentConfiguration(
domain=options["domain"].decode("ascii"),
kubernetes_namespace=options["kubernetes-namespace"].decode("ascii"),
subscription_manager_endpoint=URL.fromText(options["endpoint"].decode("ascii")),
s3_access_key_id=access_key_id.decode("ascii"),
s3_secret_key=secret_access_key.decode("ascii"),
introducer_image=options["introducer-image"].decode("ascii"),
storageserver_image=options["storageserver-image"].decode("ascii"),
log_gatherer_furl=options["log-gatherer-furl"],
stats_gatherer_furl=options["stats-gatherer-furl"],
)
return _convergence_service(
reactor,
options["interval"],
config,
subscription_client,
k8s,
aws,
)
示例2: FSItem
# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import decode [as 别名]
#.........这里部分代码省略.........
that comes around
"""
try:
jpgs = [i.path for i in self.location.children() if i.splitext()[1] in ('.jpg', '.JPG')]
try:
self.cover = jpgs[0]
except IndexError:
pngs = [i.path for i in self.location.children() if i.splitext()[1] in ('.png', '.PNG')]
try:
self.cover = pngs[0]
except IndexError:
return
except UnicodeDecodeError:
self.warning("UnicodeDecodeError - there is something wrong with a file located in %r", self.location.path)
def remove(self):
#print "FSItem remove", self.id, self.get_name(), self.parent
if self.parent:
self.parent.remove_child(self)
del self.item
def add_child(self, child, update=False):
self.children.append(child)
self.child_count += 1
if isinstance(self.item, Container):
self.item.childCount += 1
if update == True:
self.update_id += 1
def remove_child(self, child):
#print "remove_from %d (%s) child %d (%s)" % (self.id, self.get_name(), child.id, child.get_name())
if child in self.children:
self.child_count -= 1
if isinstance(self.item, Container):
self.item.childCount -= 1
self.children.remove(child)
self.update_id += 1
def get_children(self,start=0,request_count=0):
if request_count == 0:
return self.children[start:]
else:
return self.children[start:request_count]
def get_child_count(self):
return self.child_count
def get_id(self):
return self.id
def get_update_id(self):
if hasattr(self, 'update_id'):
return self.update_id
else:
return None
def get_path(self):
if isinstance( self.location,FilePath):
return self.location.path
else:
self.location
def set_path(self,path=None,extension=None):
if path is None:
path = self.get_path()
if extension is not None:
path,old_ext = os.path.splitext(path)
path = ''.join((path,extension))
if isinstance( self.location,FilePath):
self.location = FilePath(path)
else:
self.location = path
def get_name(self):
if isinstance( self.location,FilePath):
name = self.location.basename().decode("utf-8", "replace")
else:
name = self.location.decode("utf-8", "replace")
return name
def get_cover(self):
try:
return self.cover
except:
try:
return self.parent.cover
except:
return ''
def get_parent(self):
return self.parent
def get_item(self):
return self.item
def get_xml(self):
return self.item.toString()
def __repr__(self):
return 'id: ' + str(self.id) + ' @ ' + self.get_name().encode('ascii','xmlcharrefreplace')