小编use*_*146的帖子

更简单的方法来启用详细日志记录

我想添加一个调试print语句测试,如果我--verbose从命令行启用,如果我在脚本中有以下内容.

logger.info("test")
Run Code Online (Sandbox Code Playgroud)

我经历了以下问题,但无法得到答案......

python python-2.7

58
推荐指数
5
解决办法
6万
查看次数

限制命令行选项的值

如何限制argparse选项的值?

在下面的代码sau选项应该只接受了一些01bg应只允许一个整数.我该如何实现呢?

import os
import sys, getopt
import argparse

def main ():
    parser = argparse.ArgumentParser(description='Test script')
    parser.add_argument('-sau','--set',action='store',dest='set',help='<Required> Set flag',required=True)
    parser.add_argument('-bg','--base_g',action='store',dest='base_g',help='<Required> Base g',required=True)
    results = parser.parse_args() # collect cmd line args
    set = results.set
    base_g = results.base_g

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

python command-line-arguments argparse

31
推荐指数
1
解决办法
7684
查看次数

为什么git-cherrypick没有说什么

我搜索了很多以下问题,但无法获得任何实质性信息...请帮助我,创建一个临时分支202116,我正在尝试做一个gerrit 202116的樱桃,我收到以下消息,为什么我不是能够挑选这种微粒,为什么我会收到这个错误?请提供您的意见

<>git fetch ssh://company@company.com:29418/platform/vendor/company-proprietary/radio refs/changes/25/202116/1 && git cherry-pick FETCH_HEAD
From ssh://company.com:29418/platform/vendor/company-proprietary/radio
 * branch            refs/changes/25/206025/1 -> FETCH_HEAD
# On branch 202116
# You are currently cherry-picking.
#   (all conflicts fixed: run "git commit")
#
nothing to commit, working directory clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty
Run Code Online (Sandbox Code Playgroud)

git github gerrit git-cherry-pick

31
推荐指数
1
解决办法
3万
查看次数

转换目录中所有文件的dos2unix行结尾

Curretly我使用以下命令来更改dos2unix行结尾,但这是for file-y file ..有一种方法可以对目录中的所有文件运行此命令

sed -i 's/\r//' filename
Run Code Online (Sandbox Code Playgroud)

谢谢,

awk sed

21
推荐指数
3
解决办法
3万
查看次数

在grepping消息时,bufsize必须是整数错误

在尝试grep包含日志中的多行行的消息时,我遇到了以下错误...任何人都可以提供有关如何克服此错误的输入吗?

码:-

    print gerrit_commitmsg
    gerritlog = Popen('git','log','--grep','gerrit_commitmsg', stdout=PIPE, stderr=PIPE)
    print gerritlog
Run Code Online (Sandbox Code Playgroud)

错误:-

Commit message:-

Build system changes

Build system changes to include packages in the build

Change-Id: I697558f01ae367d2baacdf2c7fcf1a03753edacd

Traceback (most recent call last):
  File "gerrits_in_workspace.py", line 87, in <module>
    main()
  File "gerrits_in_workspace.py", line 77, in main
    grep_commitmsg(gerrit_commitmsg)
  File "gerrits_in_workspace.py", line 48, in grep_commitmsg
    gerritlog = Popen('git','log','--grep','gerrit_commitmsg', stdout=PIPE, stderr=PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 629, in __init__
    raise TypeError("bufsize must be an integer")
Run Code Online (Sandbox Code Playgroud)

python subprocess

8
推荐指数
1
解决办法
2万
查看次数

以递归方式更改目录中文件的权限

我正在尝试使用以下命令更改目录和子目录中存在的文件的权限,并运行到下面的错误..谁可以帮助?

user@machine:/local/mnt/workspace$ find . -type f -exec chmod 644 {} \;
chmod: changing permissions of `./halimpl/ncihal/adaptation/NonVolatileStore.cpp': Operation not permitted
Run Code Online (Sandbox Code Playgroud)

linux find chmod

4
推荐指数
1
解决办法
2万
查看次数

如何重置为特定提交?

当我执行"git log --oneline"时,我有以下最近的提交...我想重置为"8ec2027",我尝试了一些无效的rebase命令..这是什么命令才能做到这一点?

2503013 code: cs release 1.2.3.47
269ed14 code: Fixed below issues due to which 2nd client is not associating to GO
dca02a3 code: Donot allow the scan during WPS/EAPOL exchange.
b2fee57 code: MCC Adaptive Scheduler
6af29c4 code: Not able to connect more then 10 STA
150aacd code: Fix the Max Tx power value in 5G band and .ini support for 11h
8ec2027 Merge "code: cs release 1.2.3.46"
9015b60 Merge "code: Quarky Support on Prima"
......
Run Code Online (Sandbox Code Playgroud)

git version-control gerrit

3
推荐指数
1
解决办法
3988
查看次数

如何从我的提交中删除一些文件

我已经上传了一个Gerrit,现在我想从提交中删除一些文件,我该怎么做?

git github gerrit

2
推荐指数
2
解决办法
1万
查看次数

合并两个if语句

我想结合以下陈述

    if "%s\n" % baseAU in out:
        print "Match"
        count = 1

    if internaldep in pendinggerrits:
        print "match"
        count = 1
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法,但是有没有更简单的方法

    if  "%s\n" % baseAU in out and internaldep in pendinggerrits:
        print "match"
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
7217
查看次数