Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:00:05+00:00 2026-06-12T16:00:05+00:00

Part of my code: import subprocess import logging logging.basicConfig(filename=’daily_backup_run.log’, level=logging.DEBUG) try: git_command = subprocess.Popen(git

  • 0

Part of my code:

import subprocess
import logging
logging.basicConfig(filename='daily_backup_run.log', level=logging.DEBUG)

try:
  git_command = subprocess.Popen("git status", shell="true")
  git_status_output = git_command.stdout.readline()
except subprocess.CalledProcessError, e:
  git_status_output = e.output
logging.debug(' Output of git status: ' + git_status_output)
exit()

When I attempt to run this, my output is:

[~/experiment_folder]# python git.py
Traceback (most recent call last):
  File "git.py", line 35, in ?
    except subprocess.CalledProcessError, e:
AttributeError: 'module' object has no attribute 'CalledProcessError'
fatal: Not a git repository (or any of the parent directories): .git

I am not concerned with the Python errors at the moment, but I need all output sent by git to go into the daily_backup_run.log – even the fatal: Not a repo error. How do I ensure this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:00:07+00:00Added an answer on June 12, 2026 at 4:00 pm

    From the Subprocess module documentation:

    stdin, stdout and stderr specify the executed program’s standard input, standard output and standard error file handles, respectively. Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created.

    You can modify the code as follows:

    # working dir in which git [command] is called
    cwd = '/path/to/git/repository' 
    
    p = subprocess.Popen("git status", shell="true", cwd=cwd,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    outdata, errdata = p.communicate()
    
    logging.debug('Output of git status: {}. Error data if any: {}'
                  .format(outdata, errdata))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at how to import some third part code into a git repository.
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');
I want to test my part of code that returns the users password question.
I'm having a problem with a part of code. It should work,since it is
I am trying to learn and writting this part of code. while testing few
Suppose I have a Markdown string: * Bullet has *bold [code]*test[/code] part*. *Another\nbold* item.
i have this simple question please. I have this part of code which sets
I'm stuck on one thing i can't get solved. I have part of code,
I'm studying data structures (List, Stack, Queue), and this part of code is confusing
Part of my code I get the OuterHTML propery <LI onclick=TabClicked(this, 'SearchName', 'TabGroup1');>Name so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.