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


Python sys.stderr函数代码示例

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


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

示例1: main_style

def main_style(args):
    if args.ci:
        # When the command is run in CI mode all the other parameters are ignored
        selected_modules = automation_path.filter_user_selected_modules(None)

        # Run pylint on all modules
        return_code_sum = run_pylint(selected_modules)

        # Run flake8 on modules
        return_code_sum += run_pep8(selected_modules)

        sys.exit(return_code_sum)

    selected_modules = automation_path.filter_user_selected_modules(args.modules)
    if not selected_modules:
        sys.stderr('No module is selected.\n')
        sys.exit(1)

    if not args.suites:
        return_code_sum = run_pylint(selected_modules) + run_pep8(selected_modules)
    else:
        return_code_sum = 0
        if 'pep8' in args.suites:
            return_code_sum += run_pep8(selected_modules)

        if 'pylint' in args.suites:
            return_code_sum += run_pylint(selected_modules)

    sys.exit(return_code_sum)
开发者ID:derekbekoe,项目名称:azure-cli,代码行数:29,代码来源:__init__.py

示例2: check_user_config

 def check_user_config(self):
     if not os.path.isdir(self.user_config_dir):
         try:
             os.mkdir(self.user_config_dir, 0777)
         except (IOError, os.error), value:
             sys.stderr("Cannot write preferences into %s." % user_config_dir)
             sys.exit(1)
开发者ID:sk1project,项目名称:sk1-tk,代码行数:7,代码来源:configurator.py

示例3: pepperoni

def pepperoni(source, d, backup, write, rules):
    """
    Pepperoni will read the python file SOURCE and modify it to match PEP008 standards
    """

    if source:
        with open(source, "rb") as fh:
            data = fh.readlines()

        if data:
            corrected = utils.parse_file(data, rwd=rules)
            if d:
                dest = d
            else:
                if backup:
                    dest = utils.bak_file(source)
                else:
                    dest = source

            if write:

                with open(source, "wb") as fh:
                    fh.writelines(data)
                with open(dest, "wb") as fh:
                    fh.writelines(corrected)
            else:
                sys.stderr(corrected)
    else:
        print "Warning: No python file passed. Nothing was changed."
开发者ID:Ahuge,项目名称:Pepperoni,代码行数:29,代码来源:core.py

示例4: makeNormalSequence

def makeNormalSequence ( bc, time=0, outfields=['*'], detfields=['*'], outhead=True, dethead=True ):
    seq = []
    params = bc['header'].get('chosen_param', None)
    timestep = bc['header'].get('time_step', None)
    
    if not params:
        return seq
    
    if ( timestep ):
        timestep = float(timestep[0])
        for row in bc['data']:
            if len(row) != len(params):
                print >> sys.stderr('Data row length does not match declared parameters')
            seq.append({'type':'=', 'n':1, 'start':time, 'end':time + timestep,
                        'duration':timestep, 'setfields':params, 'setvalues':row,
                        'outfields':outfields, 'detfields':detfields,
                        'outhead':outhead, 'dethead':dethead})
            time = time + timestep
            outhead = False
            dethead = False
    else:
        for row in bc['data']:
            duration = float(row[0])
            if len(row) != len(params) + 1:
                print >> sys.stderr('Data row length does not match declared parameters')
            seq.append({'type':'=', 'n':1, 'start':time, 'end':time + duration,
                        'duration':timestep, 'setfields':params, 'setvalues':row[1:],
                        'outfields':outfields, 'detfields':detfields,
                        'outhead':outhead, 'dethead':dethead})
            time = time + duration
            outhead = False
            dethead = False
    
    return seq
开发者ID:bcmd,项目名称:BCMD,代码行数:34,代码来源:steps.py

示例5: make_cells

def make_cells(args):

  if len(args) < 2:
    print sys.stderr('expected 2 arguments')
    sys.exit(1)

  size = args[0]
  seed_size = args[1]

#cell  cell0 (clk, op, 0, rule, state[4:3], state[1:0], state[2]);

  for i in xrange(size - 1, -1, -1):

    r = ((i - 2 + size) % size, (i - 1 + size) % size)
    l = ((i + 1) % size, (i + 2) % size)

    if l[0] + 1 == l[1]:
      left = 'state[%d:%d]' % (l[1], l[0])
    else:
      left = '{state[%d], state[%d]}' % (l[1], l[0])

    if r[0] == r[1] - 1:
      right = 'state[%d:%d]' % (r[1], r[0])
    else:
      right = '{state[%d], state[%d]}' % (r[1], r[0])

    cell = 'state[%d]' % (i)

    if i < seed_size:
      seed = 'seed[%d]' % (i)
    else:
      seed = '1\'b0';

    print 'cell_state cell' + repr(i) + '(clk, op, ' + seed + ', rule, ' + \
          left + ', ' + cell + ', ' + right + ');'
开发者ID:allagar,项目名称:junkcode,代码行数:35,代码来源:main-cells.vv.py

示例6: add_color

 def add_color(self, html_color, name):
     """Add color to used color, if there is no name for color, method will generate some name"""
     self.add_package("color")
     #hex->dec
     if len(html_color) == 4:  #triple color code
         color = (int(html_color[1], 16), int(html_color[2], 16), int(html_color[3], 16))
     else:
         color = (int(html_color[1:3], 16), int(html_color[3:5], 16), int(html_color[5:7], 16))
     #get name
     if name:
         if name in self._defined_colors and self._defined_colors[name] == color:
             return name         #we have already defined this color
         if name in self._defined_colors and not self._defined_colors[name] == color:
             #we have same name but different color codes, so we create new name by adding number to it
             i = 1
             while name + str(i) in self._defined_colors:
                 i += 1
             self._defined_colors[name + str(i)] = color
             self._other.append("\\definecolor{" + name + str(i) + "}{RGB}{" + ",".join((str(x) for x in color)) + "}")
             return name + str(i)
         #we have unique name so we just add it
         self._defined_colors[name] = color
         self._other.append("\\definecolor{" + name + "}{RGB}{" + ",".join((str(x) for x in color)) + "}")
         return name
     else:
         sys.stderr("Invalid name for color")
开发者ID:Rixsus,项目名称:PyHtmlToLatex,代码行数:26,代码来源:ProgConf.py

示例7: get_environ

def get_environ():
        environ = {}
        environ["KONIX_PLATFORM"] = sys.platform
        logging.info("Installing for platform "+environ["KONIX_PLATFORM"])
        KONIX_PWD = os.getcwd().replace("\\","/")
        environ["KONIX_DEVEL_DIR"] = KONIX_PWD
        environ["KONIX_BIN_DIR"] = environ["KONIX_DEVEL_DIR"]+"/"+"bin"
        environ["KONIX_LIB_DIR"] = environ["KONIX_DEVEL_DIR"]+"/"+"lib"
        environ["KONIX_SHARE_DIR"] = environ["KONIX_DEVEL_DIR"]+"/"+"share"
        environ["KONIX_SRC_DIR"] = environ["KONIX_DEVEL_DIR"]+"/"+"src"
        # add the lib dir to sys path in order to use the which lib so that I
        # can find python executable. sys.executable won't work with cygwin
        sys.path.insert(0, environ["KONIX_LIB_DIR"])
        import which
        python_bin = which.which("python").replace("\\", "/")
        if python_bin == "":
            sys.stderr("Python must be in the path for that install to work")
            exit(1)
        environ["PYTHON_BIN"] = python_bin
        logging.info("Python bin is : "+python_bin)
        environ["PYTHON_PATH"] = os.path.dirname(python_bin)
        environ["KONIX_PWD"] = KONIX_PWD
        environ["KONIX_CONFIG_DIR"] = KONIX_PWD+"/"+"config"
        environ["KONIX_TUNING_DIR"] = KONIX_PWD+"/"+"tuning"
        environ["HOME"] = os.path.expanduser("~").replace("\\","/")
        environ["KONIX_PERSO_DIRS"] = os.path.join(environ["HOME"], "perso")
        environ["KONIX_PERSO_DIR"] = os.path.join(environ["KONIX_PERSO_DIRS"], "perso")
        environ["PATH_SEPARATOR"] = os.pathsep
        environ["HOSTNAME"] = os.environ["HOSTNAME"]
        environ["KONIX_SH_CUSTOM_FILE"] = environ["HOME"]+"/"+".shrc_custo"
        environ["KONIX_EMACS_CUSTOM_FILE"] = environ["HOME"]+"/"+".emacs_custo"
        return environ
开发者ID:Konubinix,项目名称:Devel,代码行数:32,代码来源:install_lib.py

示例8: main

def main():
  if len(sys.argv) < 3:
    print >> sys.stderr, ('Usage: %s <JSON files...> <output C++ file>' %
                          sys.argv[0])
    print >> sys.stderr, sys.modules[__name__].__doc__
    return 1

  cpp_code = CC_HEADER
  for json_file in sys.argv[1:-1]:
    with open(json_file, 'r') as f:
      json_text = f.read()
    config = json.loads(json_text)
    if 'monitored_domain' not in config:
      print >> sys.stderr ('%s: no monitored_domain found' % json_file)
      return 1
    domain = config['monitored_domain']
    if not domain_is_whitelisted(domain):
      print >> sys.stderr ('%s: monitored_domain "%s" not in whitelist' %
                           (json_file, domain))
      return 1
    cpp_code += "  // " + json_file + ":\n"
    cpp_code += quote_and_wrap_text(json_text) + ",\n"
    cpp_code += "\n"
  cpp_code += CC_FOOTER

  with open(sys.argv[-1], 'wb') as f:
    f.write(cpp_code)

  return 0
开发者ID:Cr33pyGuy,项目名称:chromium,代码行数:29,代码来源:bake_in_configs.py

示例9: select_from_x_pictures

def select_from_x_pictures(num_to_get, subreddit):

    try:
        reddit = praw.Reddit(user_agent='wallpaper_grabber')
        subs = reddit.get_subreddit(subreddit).get_hot(limit=num_to_get)
    except praw.errors.InvalidSubreddit:
        sys.stderr("Subreddit doesn't exist")
        sys.exit()

    filter_name = "^(.*[\\\/])"  # This removes everything but after the last /

    image = None
    submissions = []
    for img in subs:
        if ".png" in img.url.lower() or ".jpg" in img.url.lower():
            submissions.append(img.url)
            attempts = 0

    while attempts < num_to_get:
        try:
            check_file_exits()
            image = random.choice(submissions)
            filename = "wallpapers/" + re.sub(filter_name, '', image)
            file = requests.get(image)
            with open(filename, 'wb') as img:
                img.write(file.content)
                image = filename
        except:
            sys.stderr.write("Problem with downloading image")
            attempts += 1
            continue
        return image
开发者ID:SirSharpest,项目名称:reddit_wallpaper_grabber,代码行数:32,代码来源:main.py

示例10: build_file

def build_file(infile, outfile):

    try:
        f = open(infile)
    except IOError, msg:
        sys.stderr("Could not open input file '%s' : %s\n", infile, msg)
        sys.exit(1)
开发者ID:dallingham,项目名称:regenerate,代码行数:7,代码来源:mk_regs.py

示例11: communityMining

def communityMining(G, minCommSize=10):
  """
  Find communities in the graph 'G' with more than 'minCommSize' nodes.
  """
  count = 0
  dendrogram = community.generate_dendrogram(G)
  firstPartition = community.partition_at_level(dendrogram,0)
  
  sys.stderr.write("Prune sparse clusters. ")
  #remove early small communities 
  sparseComm = set([k for k,v in Counter(firstPartition.values()).iteritems() if v<minCommSize])
  nodes = [node for node in G.nodes() if firstPartition[node] in sparseComm]
  G.remove_nodes_from(nodes)

  sys.stderr.write("Find communities. ")
  # Partition again the graph and report big communities:
  dendrogram = community.generate_dendrogram(G)
  partition = community.partition_at_level(dendrogram,len(dendrogram)-2)
  allfqdns =  set(n for n,d in G.nodes(data=True) if d['bipartite']==1)
  allHosts = set(n for n,d in G.nodes(data=True) if d['bipartite']==0)
  size = float(len(set(partition.values())))
  communities = []
  
  bigComm = [k for k,v in Counter(partition.values()).iteritems() if v>minCommSize]
  for com in bigComm :
    comfqdns = [nodes for nodes in allfqdns if partition[nodes] == com]
    comHosts = [nodes for nodes in allHosts if partition[nodes] == com]
    comm = G.subgraph(comfqdns+comHosts) 
    if comm.order() < minCommSize :
        sys.stderr("Remove small community (This shouldn't happen here?)\n")
        continue

    communities.append(comm)
    
  return communities 
开发者ID:necoma,项目名称:matatabi_script,代码行数:35,代码来源:findSuspiciousDnsFailures.py

示例12: get_emit_index

def get_emit_index(input_val, alphabet):
    
    for i in range(0, len(alphabet)):
        if alphabet[i] == input_val:
            return i

    sys.stderr("Could not find character " + input_val)
开发者ID:ziruixiao,项目名称:Genome-Sequencing,代码行数:7,代码来源:Viterbi.py

示例13: make_h10giao

def make_h10giao(mol, dm0, with_gaunt=False, verbose=logger.WARN):
    if isinstance(verbose, logger.Logger):
        log = verbose
    else:
        log = logger.Logger(mol.stdout, verbose)
    log.debug('first order Fock matrix / GIAOs')
    n4c = dm0.shape[0]
    n2c = n4c // 2
    c = mol.light_speed

    tg = mol.intor('cint1e_spgsp', 3)
    vg = mol.intor('cint1e_gnuc', 3)
    wg = mol.intor('cint1e_spgnucsp', 3)

    vj, vk = _call_giao_vhf1(mol, dm0)
    h1 = vj - vk
    if with_gaunt:
        sys.stderr('NMR gaunt part not implemented')
#TODO:        import pyscf.lib.pycint as pycint
#TODO:        vj, vk = scf.hf.get_vj_vk(pycint.rkb_giao_vhf_gaunt, mol, dm0)
#TODO:        h1 += vj - vk

    for i in range(3):
        h1[i,:n2c,:n2c] += vg[i]
        h1[i,n2c:,:n2c] += tg[i] * .5
        h1[i,:n2c,n2c:] += tg[i].conj().T * .5
        h1[i,n2c:,n2c:] += wg[i]*(.25/c**2) - tg[i]*.5
    return h1
开发者ID:berquist,项目名称:pyscf,代码行数:28,代码来源:dhf_nmr.py

示例14: daemon

 def daemon(self):
     try:
         if os.fork():
             sys.exit(0)
     except OSError, e:
         sys.stderr('%s, %d, %s' % ('Fork #1 failed', e.errno, e.strerror))
         sys.exit(1)
开发者ID:jhazheng,项目名称:monitors,代码行数:7,代码来源:daemon.py

示例15: MakeConfig

def MakeConfig(opts):
	"""
	MakeConfigurationParameters

	Create Configuration list from command options
	"""
	prof_list = []
	cnt = 0
	for opt, arg in opts:
		if opt == ("--config"):
			try:
				# For C++ scope resolution operator 
				arg = re.sub("::", "@@", arg)
				name, type, default = arg.split(":")
				name    = re.sub("@@", "::", name)
				type    = re.sub("@@", "::", type)
				default = re.sub("@@", "::", default)
			except:
				sys.stderr("Invalid option: " \
					   + opt \
					   + "=" \
					   + arg)
			prof = Struct()
			prof.name = name
                        prof.l_name = name.lower()
                        prof.u_name = name.upper()
			prof.type = type
			prof.default  = default
			prof_list.append(prof)
			cnt += 1
	return prof_list
开发者ID:yosuke,项目名称:OpenRTM-aist-Python,代码行数:31,代码来源:rtc-template.py


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