本文整理匯總了Python中dropbox.Dropbox.files_move方法的典型用法代碼示例。如果您正苦於以下問題:Python Dropbox.files_move方法的具體用法?Python Dropbox.files_move怎麽用?Python Dropbox.files_move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dropbox.Dropbox
的用法示例。
在下文中一共展示了Dropbox.files_move方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: rpiImageDbxClass
# 需要導入模塊: from dropbox import Dropbox [as 別名]
# 或者: from dropbox.Dropbox import files_move [as 別名]
#.........這裏部分代碼省略.........
# Select only images and only the ones for the current imgid (camid)
foundImg = False
for f in self.ls_ref.entries:
if 'media_info' in f._all_field_names_ and \
f.media_info is not None:
if self.imgid in f.path_lower:
img = '.%s' % f.path_lower
foundImg = True
if not img in self.imageDbList:
self.imageDbList.append(img)
if not foundImg:
self.imageDbList = []
### Store the hash of the folder
self._imageDbCursor = self.ls_ref.cursor
if len(self.imageDbList) > 0:
logging.debug("%s::: _lsImage():: imageDbList[0..%d]: %s .. %s" % (self.name, len(self.imageDbList)-1, self.imageDbList[0], self.imageDbList[-1]) )
else:
logging.debug("%s::: _lsImage():: imageDbList[]: empty" % self.name)
except ApiError as e:
raise rpiBaseClassError("_lsImage(): %s" % e.error, ERRLEV2)
def _putImage(self, from_path, to_path, overwrite=False):
"""
Copy local file to remote file.
Stores the uploaded files names in self.imageUpldFIFO.
Examples:
_putImage('./path/test.jpg', '/path/dropbox-upload-test.jpg')
"""
try:
mode = (WriteMode.overwrite if overwrite else WriteMode.add)
with open(from_path, "rb") as from_file:
self._dbx.files_upload( from_file, '/' + os.path.normpath(to_path), mode)
if not overwrite:
self.imageUpldFIFO.append(from_path)
logging.debug("%s::: _putImage(): Uploaded file from %s to remote %s" % (self.name, from_path, to_path))
except IOError:
raise rpiBaseClassError("_putImage(): Local img file %s could not be opened." % from_path, ERRCRIT)
except ApiError as e:
raise rpiBaseClassError("_putImage(): %s" % e.error, ERRLEV2)
def _mkdirImage(self, path):
"""
Create a new remote directory.
Examples:
_mkdirImage('/dropbox_dir_test')
"""
try:
self._dbx.files_create_folder('/' + os.path.normpath(path))
logging.debug("%s::: Remote output folder /%s created." % (self.name, path))
except ApiError as e:
noerr = False
# dropbox.files.CreateFolderError
if e.error.is_path():
# dropbox.files.WriteError
we = e.error.get_path()
if we.is_conflict():
# dropbox.files.WriteConflictError
wce = we.get_conflict()
# union tag is 'folder'
if wce.is_folder():
logging.info("%s::: Remote output folder /%s already exist!" % (self.name, path))
noerr = True
if not noerr:
raise rpiBaseClassError("_mkdirImage(): Remote output folder /%s was not created! %s" % (path, e.error), ERRCRIT)
else:
pass
def _mvImage(self, from_path, to_path):
"""
Move/rename a remote file or directory.
Examples:
_mvImage('./path1/dropbox-move-test.jpg', '/path2/dropbox-move-test.jpg')
"""
try:
self._dbx.files_move( '/' + os.path.normpath(from_path), '/' + os.path.normpath(to_path) )
logging.debug("%s::: _mvImage(): Moved file from %s to %s" % (self.name, from_path, to_path))
except ApiError as e:
raise rpiBaseClassError("_mvImage(): Image %s could not be moved to %s! %s" % (from_path, to_path, e.error), ERRLEV2)