admin管理员组

文章数量:1661414

我想使用Python语言从给定的FileShare位置获取文件名列表(仅限)。这是我的代码片段,但它没有列出任何文件。在import os

from os import walk

SQLSR_USER= 'username'

SQLSR_PASS= 'password'

BACKUP_REPOSITORY_PATH= '\\fileshare\location'

fileList = []

backup_storage_available = os.path.isdir(BACKUP_REPOSITORY_PATH)

if backup_storage_available:

print("Backup storage already connected.")

else:

print("Connecting to backup storage.")

mount_command = "net use /user:" + SQLSR_USER + " " + BACKUP_REPOSITORY_PATH + " " + SQLSR_PASS

os.system(mount_command)

backup_storage_available = os.path.isdir(BACKUP_REPOSITORY_PATH)

if backup_storage_available:

print ("Connection success.")

else:

raise Exception("Failed to find storage directory.")

for (dirpath, dirnames, filenames) in walk(backup_storage_available):

fileList.extend(filenames)

break

if (len(fileList) > 1):

print "\n\n *********************Required data files are present in the FileShare*********************"

else:

print "\n\n ********************* No files are present to start the Next Run *********************"

我仍然有一个网络使用连接命令列出的问题

^{pr2}$

本文标签: 密码共享文件夹用户名文件网络