0

So I am getting the issue using gitpython:

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

My code

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

My goal is to push a submodule newly added (created/updated) files to gerrit.

Edit: Request from @Arount

Ok, so I have a function called

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

The arguments has following values:

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

Inside my del_proj_gerrit function I have:

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

Inside my commit_and_push function I have:

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

Inside the commit_command_line function I have:

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
user535081
  • 13
  • 7
  • @Arount Check my edit – user535081 Jul 10 '17 at 13:09
  • Never actually use the function traceback before. Do you sugget `traceback.print_exc()`? because when i do that I get None. From the documentation I read it seems like I need to use `try & except`. The thing is I get the **Push master:refs/for/master No handlers could be found for logger "git.remote"** when I am trying to push it seems like. In other words, I don't get any errors :(. The function I pasted above are the relevants one (maybe not best format). – user535081 Jul 10 '17 at 13:33
  • @Arount `No handlers could be found for logger…` is a warning, not an error, so no traceback. – phd Jul 10 '17 at 13:48
  • The problem is that GitPython creates a logger with `getLogger('git.remote')` (and many other BTW) and logging is not configured for these loggers. – phd Jul 10 '17 at 13:52
  • @phd So is there any possibility where I can configure the loggers? Can I find these loggers somwhere in my git repo project? – user535081 Jul 10 '17 at 14:00

1 Answers1

1

GitPython uses python logging so you just have to configure it. As per docs the minimal configuration is:

import logging
logging.basicConfig(level=logging.INFO)
phd
  • 82,685
  • 13
  • 120
  • 165
  • I see. I tried this out just to see what my refspec is: `logging.basicConfig(level=logging.INFO) logger = logging.getLogger(refspec) print logger` this gives me **logging.Logger object at 0x0000000002DD2518** while `remote.push(refspec)` gives **** – user535081 Jul 10 '17 at 14:21
  • `logger` is your logging object. Call logging methods on it: `logger.info("Refspec: %s", refspec)` etc. – phd Jul 10 '17 at 14:25
  • Well at least I got something now :) : `WARNING:git.remote:Error lines received while fetching: error: failed to push so me refs to 'ssh://url:port/repo-project'`. – user535081 Jul 10 '17 at 14:46
  • I think have gotten this problem before as well when I tried to push something with a python script. Might be something locally wrong my configuration – user535081 Jul 11 '17 at 06:19