当前位置: 首页>>代码示例>>Python>>正文


Python sys.sysexit函数代码示例

本文整理汇总了Python中sys.sysexit函数的典型用法代码示例。如果您正苦于以下问题:Python sysexit函数的具体用法?Python sysexit怎么用?Python sysexit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sysexit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_config

def load_config(configdb, args = None):
    args = argv[1:] if args is None else args
    set_debug_details(args.count('--debug')+args.count('-d'))

    default_config = config.DefaultValueLoader().load(configdb)
    _logger.info('default config:\n\t%s', config.pretty(default_config, '\n\t'))

    # parse cli options at first because we need the config file path in it
    cli_config = config.CommandLineArgumentsLoader().load(configdb, argv[1:])
    _logger.info('cli arg parsed:\n\t%s', config.pretty(cli_config, '\n\t'))
    run_config = config.merge_config(default_config, cli_config)

    if run_config.generate_config:
        generate_config_file(configdb, run_config)

    try:
        conf_config = config.from_file(configdb, run_config.config_file)
    except config.ConfigFileLoader.ConfigValueError as err:
        _logger.error(err)
        sysexit(1)

    _logger.info('config file parsed:\n\t%s', config.pretty(conf_config, '\n\t'))
    run_config = config.merge_config(run_config, conf_config)

    # override saved settings again with cli options again, because we want
    # command line options to take higher priority
    run_config = config.merge_config(run_config, cli_config)
    if run_config.setter_args:
        run_config.setter_args = ','.join(run_config.setter_args).split(',')
    else:
        run_config.setter_args = list()
    _logger.info('running config is:\n\t%s', config.pretty(run_config, '\n\t'))
    return run_config
开发者ID:yanghuatjy,项目名称:pybingwallpaper,代码行数:33,代码来源:main.py

示例2: get_studies

 def get_studies(self, subj_ID, modality=None, unique=True, verbose=False):    
     
     url = 'studies?' + self._login_code + '\\&projectCode=' + self.proj_code + '\\&subjectNo=' + subj_ID 
     output = self._wget_system_call(url)
 
     # Split at '\n'
     stud_list = output.split('\n')
     # Remove any empty entries!
     stud_list = [x for x in stud_list if x]
 
     if modality:
         for study in stud_list:
             url = 'modalities?' + self._login_code + '\\&projectCode=' + self.proj_code + '\\&subjectNo=' + subj_ID + '\\&study=' + study
             output = self._wget_system_call(url).split('\n')
             #print output, '==', modality
             
             for entry in output:              
                 if entry == modality:
                     if unique:
                         return study
                         ### NB!! This only matches first hit! If subject contains several studies with this modality, 
                         ### only first one is returned... Fixme
                     else:
                         # must re-write code a bit to accommodate the existence of
                         # several studies containing the desired modality...
                         print "Error: non-unique modalities not implemented yet!"
                         sysexit(-1)
                     
         # If we get this far, no studies found with the desired modality    
         return None 
         
     else:    
         return stud_list
开发者ID:cjayb,项目名称:mindlab_dicomdb_access,代码行数:33,代码来源:database.py

示例3: throwError

def throwError(msg):
	"""
	Throws error and exists
	"""
	drawline('#', msg)
	print("ERROR :", msg)
	sysexit()
开发者ID:aviaryan,项目名称:series-renamer,代码行数:7,代码来源:series_renamer.py

示例4: main

def main():
    """Main function."""
    parser = argparse.ArgumentParser(description='RSPET Server module.')
    parser.add_argument("-c", "--clients", nargs=1, type=int, metavar='N',
                        help="Number of clients to accept.", default=[5])
    parser.add_argument("--ip", nargs=1, type=str, metavar='IP',
                        help="IP to listen for incoming connections.",
                        default=["0.0.0.0"])
    parser.add_argument("-p", "--port", nargs=1, type=int, metavar='PORT',
                        help="Port number to listen for incoming connections.",
                        default=[9000])
    args = parser.parse_args()
    cli = Console(args.clients[0], args.ip[0], args.port[0])
    try:
        cli.loop()
    except KeyError:
        print("Got KeyError")
        cli.trash()
        del cli
        sysexit()
    except KeyboardInterrupt:
        cli.trash()
        del cli
        sysexit()
    cli.trash()
    del cli
开发者ID:dzervas,项目名称:RSPET,代码行数:26,代码来源:rspet_server.py

示例5: generate_config_file

def generate_config_file(configdb, config_content):
    filename = config_content.config_file
    _logger.info('save following config to file %s:\n\t%s',
            filename,
            config.pretty(config_content, '\n\t'))
    save_config(configdb, config_content, filename)
    sysexit(0)
开发者ID:LPLWWS,项目名称:pybingwallpaper,代码行数:7,代码来源:main.py

示例6: exit

def exit(s):
    for tile in board:
        tile.draw()
    message(s)
    pygame.display.update()
    sleep(3)
    sysexit()
开发者ID:NathanG89,项目名称:tictactoe,代码行数:7,代码来源:graphics.py

示例7: build_cache

 def build_cache(self, path=None):
     """
     Build the reverse symlink cache by walking through the filesystem and
     finding all symlinks and put them into a cache dictionary for reference
     later.
     """
     working_directory = getcwd()
     if path is None:
         bindpoint = get_bindpoint()
         if bindpoint is None:
             getLogger('files').error("No bindpoint found in the filesystem "
                                      "section of the configuration file, "
                                      "exiting")
             sysexit(1)
     else:
         bindpoint = path
     for dirname, directories, files in walk(bindpoint):
         for entry in directories + files:
             linkpath = abspath(join(dirname, entry))
             if islink(linkpath):
                 chdir(dirname)
                 destpath = abspath(readlink(linkpath))
                 if destpath in self.cache:
                     self.cache[destpath].append(linkpath)
                 else:
                     self.cache[destpath] = [linkpath]
     chdir(working_directory)
开发者ID:yourlocalbox,项目名称:LoxBox15,代码行数:27,代码来源:files.py

示例8: _set_inflow_conditions_from_bounds

    def _set_inflow_conditions_from_bounds(self,bounds):
        '''
        Set initial conditions based on Inflow-type boundary conditions.

        Search a Bounds object for Inflow boundary conditions, and generate
        an initial condition for the simulation just inside those boundaries.
        At present, only Bounds objects with only one Inflow boundary are 
        supported.
        
        Args:
          bounds: Initialized Bounds object

        Returns:
          out: Initialized array corresponding the points just bordering the
                 Inflow boundary condition.
        '''
        inflows = []
        for face in bounds:
            for patch in face:
                if patch.type is 'Inflow':
                    if not (patch.which_face == 'left' 
                            or patch.which_face == 'right'):
                        print "Inflow condition detected on eta or zeta boundary!"
                        sysexit()
                    inflows.append(patch)
            sorted(inflows, key=lambda inflow: min(inflow.bounding_points[:][2]))
#        try:
#            if len(inflows)>1:
#                raise IndexError('More than 1 Inflow condition!')
#        except IndexError:
#            print "Multiple Inflow conditions not supported!"
#            sysexit()
        initial_condition = numpy.concatenate(
            [inflow.flow_state.copy() for inflow in inflows],axis=1)
        return initial_condition
开发者ID:woodscn,项目名称:Streamer,代码行数:35,代码来源:main.py

示例9: __init__

 def __init__(self,lines):
     self.type = lines[0].strip()
     self.bounding_points = None
     self.boundary_surface = None
     self.flow_state = None
     self.fields = {'Bounding Points:':'junk',
                    'Boundary Surface:':'junk',
                    'Flow State:':'junk'}
     inds = []
     for field in self.fields.keys():
         inds.append(index_substring(lines,field))
         inds = index_substring(lines,field)
         if len(inds)>1:
             msg = "Duplicate field entries detected in Patch.__init__!"
             try:
                 raise InputFormatError(msg)
             except InputFormatError as e:
                 print e.msg
                 print 'Inds = ',inds
                 print 'Field = ',field
                 print 'Lines = ',lines
                 sysexit()
         elif not inds:
             self.fields[field] = None
         for ind in inds:
             self.read_field(lines[ind:ind+3])
     sysexit()
开发者ID:woodscn,项目名称:Streamer,代码行数:27,代码来源:BoundaryConditions_old.py

示例10: __init__

    def __init__(self,default_bounds,stl_bounds_file=None,num_faces=0):
        '''
        Initialize Bounds object.

        Args:
          default_bounds: Default_bounds is a description of a boundary surface.
            It may be superceded by other boundary conditions such as solid
            walls defined in an STL file. It is an object containing one 
            element for each Face.
          stl_bounds_file: Filename string of an ASCII .stl file describing any
            solid wall geometries present. Will eventually support the results 
            of an stl_read command (a list of arrays of nodes and faces).
          num_faces: Integer number of individual faces in the .stl file. Must
            be present if an STL file is given.
        Returns:
          self.left_face
          self.right_face
          self.top_face
          self.bottom_face
          self.back_face
          self.front_face
        Raises:
          STLError: There was an error reading the .stl file.
        '''
        # Read STL file, returning lists of triangulation vertices, indices of
        # the vertices associated with triangles, and the normal vectors of
        # those triangles.
        if stl_bounds_file:
            print " Warning: STL boundaries are not yet implemented."
            sysexit()
            num_nodes = num_faces*3
            [self.stl_nodes,self.stl_face_nodes,self.stl_face_normal,
             error]=stl.stla_read(stl_bounds_file,num_nodes,num_faces)
            if error:
                try:
                    str="STLError: stla_read failed in BoundaryConditions.__init__"
                    raise STLError(str)
                except STLError as e:
                    print e.msg
                    sysexit()

        # Isolate the parts of the boundary specification pertaining to each
        # Side and pass them on.
        self.left_face = Face('left',default_bounds.left_face)
        self.right_face = Face('right',default_bounds.right_face)
        self.bottom_face = Face('bottom',default_bounds.bottom_face)
        self.top_face = Face('top',default_bounds.top_face)
        self.back_face = Face('back',default_bounds.back_face)
        self.front_face = Face('front',default_bounds.front_face)
        fortran_normal_src = "! -*- f90 -*-\n"
        for face in self:
            for patch in face:
                try:
                    fortran_normal_src += patch.gradsrc
                except AttributeError: # Some patches don't have normal vectors
                    pass
        f2py.compile(fortran_normal_src,modulename='FortranNormalVectors',
                     verbose=False,source_fn='FortranNormalVectors.f90',
                     extra_args='--quiet')
开发者ID:woodscn,项目名称:Streamer,代码行数:59,代码来源:temp.py

示例11: _next_crossing

def _next_crossing(a,lowlim):
    for a_ind,val in enumerate(a):
        if val > lowlim:
            return a_ind
    
    print 'ERROR: No analogue trigger found within %d samples of the digital trigger' % a_ind
    print 'Cannot continue, aborting...'
    sysexit(-1)
开发者ID:cjayb,项目名称:VSC-MEG-analysis,代码行数:8,代码来源:scr_extract_and_correct_events.py

示例12: get_map_template

def get_map_template():
    global map_template
    if map_template is None:
        with open("map-template.html", 'r') as infile:
            map_template = infile.read()    
    if map_template is None:
        stderr("ERROR: cannot find HTML template: map-template.html\n")
        sysexit(1)
    return map_template
开发者ID:Justin95,项目名称:ece368-warlight,代码行数:9,代码来源:wl2dot.py

示例13: loadMap

 def loadMap(self,bgsize,mapname):
     self.current = mapname
     if os.path.exists(os.path.join('mapfiles',str(self.current))):
         self.getmovelist()
         self.getmapproperties()
         return self.backgroundGen(bgsize)
     else:
         print "You Won!!!"
         sysexit(1)
开发者ID:duckfin,项目名称:Python-Pygame-Tower-Defence,代码行数:9,代码来源:localdefs.py

示例14: clean_exit

def clean_exit():
    print
    print
    print("\nAction aborted by user. Exiting now")
    for pid in getoutput("ps aux | grep mdk3 | grep -v grep | awk '{print $2}'").splitlines():
        system("kill -9 " + pid)
    print("Hope you enjoyed it ;-)")
    sleep(2)
    system("clear")
    sysexit(0)
开发者ID:carriercomm,项目名称:scripts-6,代码行数:10,代码来源:AP-Fucker.py

示例15: loadMap

 def loadMap(self,bgsize,mapname):
     self.xpbar = pygame.Rect(300,8,350,22)
     self.current = mapname
     self.iconhold = (None,0)
     if os.path.exists(os.path.join('mapfiles',str(self.current))):
         self.getmovelist()
         self.getmapproperties()
         return self.backgroundGen(bgsize)
     else:
         print "You Won!!!"
         sysexit(1)
开发者ID:karthik1729,项目名称:Accelerometer_dumbbell,代码行数:11,代码来源:localdefs.py


注:本文中的sys.sysexit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。