Python sys 模块,exec_info() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用sys.exec_info()

项目:NetPower_TestBed    作者:Vignesh2208    | 项目源码 | 文件源码
def trigger(self):

        if self.type == TRAFFIC_FLOW_ONE_SHOT:
            sleep(int(self.offset))
            print "Started command at ", str(datetime.now())
            sys.stdout.flush()
            #os.system(self.cmd + " &")
            try:
                cmd_list = self.cmd.split(' ')
                print cmd_list
                print self.cmd
                sys.stdout.flush()
                p = subprocess.Popen(cmd_list,shell=False)
            except:
                print "Error running command: ", sys.exec_info()[0]

        elif self.type == TRAFFIC_FLOW_EXPONENTIAL:
            pass
        elif self.type == TRAFFIC_FLOW_PERIODIC:
            pass
项目:faceRecognitionforRaspPi    作者:mgudesblatart    | 项目源码 | 文件源码
def read_images (path, sz=None):
        c = 0
        X,y = [], []
        for dirname, dirnames, filenames in os.walk(path):
            for subdirname in dirnames:
                subject_path = os.path.join(dirname, subdirname)
                for filename in os.listdir(subject_path):
                    try:
                        if (filename == ".drectory"):
                            continue
                        filepath = os.path.join(subject_path, filename)
                        im = cv2.imread(os.path.join(subject_path, filename), cv2.IMREAD_GRAYSCALE)

                        if (sz is not None):
                                im = cv2.resize(im, sz)
                        X.append(np.asarray(im, dtype=np.uint8))
                        y.append(c)
                    except IOError, (errno, strerror):
                            print "I/O error({0}): {1}".format(errno,strerror)
                    except:
                            print "Unexpected error:", sys.exec_info()[0]
                            raise
                c= c+1

        return [X,y]
项目:admixturePipeline    作者:smussmann82    | 项目源码 | 文件源码
def run_program(self,string):
        print(string)
        try:
            process = subprocess.Popen(string, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
            output, err = process.communicate()
            print(err)
            if process.returncode != 0:
                print("Non-zero exit status:")
                print(process.returncode)
                raise SystemExit
        except:
            print("Unexpected error:")
            print(sys.exec_info())
            raise SystemExit
项目:deb-subunit    作者:openstack    | 项目源码 | 文件源码
def _handleTime(self, offset, line):
        # Accept it, but do not do anything with it yet.
        try:
            event_time = iso8601.parse_date(line[offset:-1])
        except TypeError:
            raise TypeError(_u("Failed to parse %r, got %r")
                % (line, sys.exec_info[1]))
        self.client.time(event_time)