2017-07-10 45 views
0

所以我正在使用gitpython问题:没有处理程序可以发现记录器“git.remote”

No handlers could be found for logger "git.remote"

我的代码

print repo_object.remote() # origin 
print repo_object.active_branch # master 
print repo_object.active_branch.name # master 
refspec = repo_object.active_branch.name + ":refs/for/" + repo_object.active_branch.name 
print refspeC# master:/refs/for/master 
print "Push " + refspeC# push master:refs/for/master 
print remote.push(refspec) # [<git.remote.PushInfo object at 0x....>] 
remote.push(refspec) 

pushed_repos.append(repo_name) 
print pushed_repos # my project repo 

我的目标是推动新添加的一个子模块(创建/更新)文件到gerrit。

编辑:请从@Arount

好了,我有一个函数调用

del_proj_gerrit(pushed_repos, commit_message, repo_path, repo_name, push) 

的参数有以下值:

pushed_repos # [] 
commit_message # just a commit message 
repo_name_path # path to my local repo 
repo_name # name of the project repo 
push # A value of True is set here 

里面我del_proj_gerrit功能我:

add_all_files("./") 
    if push == True: 
    commit_and_push(pushed_repos, commit_message, repo_path, repo_name) 

里面我commit_and_push功能我:

repo_path_new = repo_path+repo_name 
repo_object = Repo(repo_path_new) # <git.Repo "C\localpath\.git\modules\repo-project"> 
if commit_command_line(commit_message, repo_object, repo_name): 
    # Inside the if-statement you have the code I posted before 

里面的commit_command_line功能我:

cmd = "git commit -m \"%s\"" % commit_message 
errmsg = "Failed command:\n" + cmd 
success = True 
try: 
    execute_shell_process(cmd, errmsg, True, True) 
except CommonProcessError as e: 
    print "Error during commit for repo '" + repo_name + "' (ret code " + \ 
     str(e.returncode) + ")." 
    print "Assuming that there was no changes to last commit => continue" 
    success = False 
return success 
+0

@Arount检查我的编辑 – user535081

+0

之前从来没有真正使用的功能回溯。你建议'traceback.print_exc()'?因为当我这样做时,我得到无。从我读的文档看来,我似乎需要使用'try&except'。事情是我得到**推大师:参考/为/主 没有处理程序可以发现记录器“git.remote”**当我试图推它似乎。换句话说,我没有得到任何错误:(。我上面粘贴的函数是相关的一个(可能不是最好的格式)。 – user535081

+0

@Arount'没有处理程序可以找到记录器...'是一个警告,而不是错误,所以没有回溯。 – phd

回答

0

GitPython使用Python记录,所以你只需要配置它。按照docs最低配置为:

import logging 
logging.basicConfig(level=logging.INFO) 
+0

我看到了。我试过这个,看看我的refspec是什么:'logging.basicConfig(level = logging.INFO) logger = logging.getLogger (refspec) print logger'这给了我** logging.Logger对象在0x0000000002DD2518 **,而'remote.push(refspec)'给出** ** – user535081

+0

'logger'是你的记录对象。调用它的日志记录方法:'logger.info(“Refspec:%s”,refspec)'等 – phd

+0

至少我现在得到了一些东西:):'警告:git.remote:错误行获取时:错误:失败推动如此 我参考'ssh:// url:port/repo-project''。 – user535081

相关问题