Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 命令对仅包含路径名和-C标志的系统的意义_Python_Shell_Command - Fatal编程技术网

Python 命令对仅包含路径名和-C标志的系统的意义

Python 命令对仅包含路径名和-C标志的系统的意义,python,shell,command,Python,Shell,Command,对不起,如果这是一个愚蠢的问题,但我是一个物理学家,不是一个程序员,所以请容忍我。我正在用GUI调试一个图像注册演示,在调试过程中出现了一些问题。该演示在最初编写它的机器上运行良好,但该机器和我的都是Windows7 64位机器。整个代码的细节或其用途其实并不重要,我已将错误缩小到代码的以下部分: def targetConvert(self): self.targetExtHeader = '.'+self.targetText.GetValue().split('.')[-1]

对不起,如果这是一个愚蠢的问题,但我是一个物理学家,不是一个程序员,所以请容忍我。我正在用GUI调试一个图像注册演示,在调试过程中出现了一些问题。该演示在最初编写它的机器上运行良好,但该机器和我的都是Windows7 64位机器。整个代码的细节或其用途其实并不重要,我已将错误缩小到代码的以下部分:

def targetConvert(self):
    self.targetExtHeader = '.'+self.targetText.GetValue().split('.')[-1]
    self.targetExtBinary = self.getBinaryFileExtension( self.targetExtHeader )

    self.targetFile = 'target_org'+self.targetExtHeader

    # split 4D data sets, currently available only when .par file format
    # is used
    if self.targetExtHeader == '.par' or self.targetExtHeader == '.PAR':
        self.logOutput.AppendText('Split target to multiple 3D images and store in tmp/ folder.\n')
        cmd = []
        cmd.append(self.lreg + ' -C ' + '\"'+self.targetText.GetValue()+'\"' + ' ' + '\"'+self.tmpFolder + self.targetFile+'\"')            

        print '\n\n\n'+cmd[0]+'\n\n\n'
        self.executeCommandList(cmd)
        ...

def executeCommandList(self, cmd):

    self.busyLabel.SetLabel(' Busy ')
    self.busyLabel.SetBackgroundColour('Red')
    self.Layout()
    self.Refresh()

    for i in range(0,len(cmd)):
        self.logOutput.AppendText( '\nCommand(s):\n' )
        self.logOutput.AppendText( cmd[i] )
        self.logOutput.AppendText( '\n\n' )
        self.process = subprocess.Popen( cmd[i], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
        while self.process.poll() is None:
            line = self.process.stdout.readline()
            self.logOutput.AppendText( line )

        # wait a second
        time.sleep(0.1)

    self.busyLabel.SetLabel('Ready')
    self.busyLabel.SetBackgroundColour(self.backgroundColorPanel)
    self.Layout()
    self.Refresh()
在executeCommandList的cmd[i]中传递给系统的命令是:

"C:\Users\310079322.CODE1\Documents\Thesis\regDemo\\lreg\\lreg.exe" -C "C:\Users\310079322.CODE1\Documents\Thesis\regDemo\ParrecImgsForRegisration\WIP_SSh_DWI_FAST_SENSE_8_1.PAR" "C:\Users\310079322.CODE1\Documents\Thesis\regDemo\\tmp\\target_org.PAR"
谷歌一直无法向我解释这个命令的用途,但我认为它不起作用。我的直觉是它应该将targetFile复制到self.tmpFolder,但我不确定,因为对于源文件,没有使用executeCommandList方法中的subprocess.open内容,而是由文件sourceConvert直接处理,如下所示:

def sourceConvert(self):
    self.sourceExtHeader = '.'+self.sourceText.GetValue().split('.')[-1]
    self.sourceExtBinary = self.getBinaryFileExtension( self.sourceExtHeader )

    self.sourceFile = 'source'+self.sourceExtHeader
    self.logOutput.AppendText('Copy source T2 to tmp/ folder.\n')

    shutil.copyfile(self.sourceText.GetValue()[:-4] + self.sourceExtHeader, self.tmpFolder + self.sourceFile[:-4] + self.sourceExtHeader)
有人能帮我解释一下这个问题吗,例如,通过executeCommand方法传递给shell的命令应该做什么,以及我遇到的实现问题是什么

致以最良好的祝愿,
Mikael

您可以尝试询问lreg.exe本身;从windows“开始”菜单运行cmd.exe,进入lreg.exe所在的文件夹,并使用-h参数运行它,如下所示:


cd\Users\310079322.CODE1\Documents\Thesis\regDemo\lreg[点击回车]
lreg.exe-h

如果lreg.exe支持命令行帮助,您应该看到所有解释的选项,以及其中的-C选项;不确定,但通常值得一试


G.

您正在运行
lreg.exe
。我们不知道这个程序是什么,但是代码看起来是正确的。谢谢你,至少还有一个问题!不知何故,我忽略了第一个路径是一个.exe文件,而只是假设它是一个数据文件,所以这就解释了为什么我不能判断命令应该运行一个程序。命令行越长-越难找到发生了什么:)刚刚注意到-C选项语法-这意味着应该有其他一些选项。