예제 #1
0
파일: console.py 프로젝트: onesuper/Easylab
    def do_autorun(self, argvstr):
        argv = argvstr.split()
        if len(argv) >= 2:
            many_argvs = autorun.argvTransform(argv)
            # run these argvs
            try:
                for argv in many_argvs:
                    p = subprocess.Popen(argv, stderr=subprocess.PIPE)
                    data = p.communicate()[1]
                    datav = data.split("\n")

                    if len(datav) == 2:
                        tablename = datav[0]
                        attrstr = datav[1]
                        attr =  autorun.stringToDict(attrstr)
                        self.database.insertOrCreateTable(tablename, attr)
            except OSError, e:
                print e
예제 #2
0
파일: console.py 프로젝트: onesuper/Easylab
    def do_run(self, argvstr):
        argv = argvstr.split()
        try:
            # read the data  from the subprocess's stdout
            p = subprocess.Popen(argv, stderr=subprocess.PIPE)

            # the format of data from std.err looks like:
            # tablename\n
            # {'key': value } 
            data  = p.communicate()[1]
            datav = data.split("\n")
            
            if len(datav) == 2:
                tablename = datav[0]
                attrstr = datav[1]
                attr =  autorun.stringToDict(attrstr)
                self.database.insertOrCreateTable(tablename, attr)
                
                
        except OSError, e:
            print e