Python和PYQT目录是

时间:2015-09-25 16:38:25

标签: python pyqt

我正在尝试使用os.system在GUI中运行命令行来帮助我们的技术人员减少办公室工作人员。我正在使用os.system ..因为我在子进程中遇到了很多麻烦。我很接近,但我得到了一个奇怪的目录路径输出..

def selectFile(self):


    self.listWidget.clear() # In case there are any existing elements in the list
    directory = QtGui.QFileDialog.getExistingDirectory(self, "Pick a folder")
    print directory


    for file_name in os.listdir(directory):
        if file_name.endswith(".csv"):
            self.listWidget.addItem(file_name)
            print (file_name)
    self.directory = directory





def osconvertfile(self):


    directoryPath = self.directory
    print directoryPath

    cmd = ('python /Users/eeamesX/work/data-scripts/longFileScripts/createXMLFromCSVSept.py '
           +str(directoryPath))
    print cmd
    os.system(cmd)

由于./被添加,我收到错误或错误的目录。

.//Users/eeamesX/work/data/Sept_1_upload/priority_2/transcriptsAudoSplits/09012015_331_male3_r1_seg1/ 

有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

您是否尝试使用os.path.normpathos.path.abspath

def osconvertfile(self):
    directoryPath = os.path.abspath(os.path.normpath(self.directory))
    print directoryPath

    cmd = 'python /Users/eeamesX/work/data-scripts/longFileScripts/createXMLFromCSVSept.py %s' directoryPath
    print cmd
    os.system(cmd)