命令对仅由路径名和C标志组成的系统的意义

2024-07-04 09:14:28 发布

您现在位置:Python中文网/ 问答频道 /正文

抱歉,如果这是一个愚蠢的问题,但我是一个物理学家,而不是一个程序员,所以请容忍我。我正在用一个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"

谷歌还没能向我解释这个命令的目的是什么,但我认为它不起作用。我的直觉是,它应该将目标文件复制到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的命令应该做什么,以及我遇到的实现问题是什么

致以最诚挚的问候, 米凯尔


Tags: selfcmd机器targetdefsplitsubprocesspar
1条回答
网友
1楼 · 发布于 2024-07-04 09:14:28

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

cd \Users\310079322.CODE1\Documents\Thesis\regDemo\lreg [hit enter] lreg.exe -h

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

G

相关问题 更多 >

    热门问题