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

  • SEARCH
  • Home
  • 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 8276245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:19:08+00:00 2026-06-08T08:19:08+00:00

I am grabbing an update from SVN via Python. I have this: try: output

  • 0

I am grabbing an update from SVN via Python.

I have this:

try: 
    output = subprocess.check_output(svn.update_cmd,
                                     stderr=subprocess.STDOUT, shell=True)
    print output
    print 'finished svn update'

    revision_number = output.split()[-1].rstrip('.') #revision number
    if log_update:
        write_update(revision_number)
    return revision_number
except subprocess.CalledProcessError, e:
    raise SVNUpdateError(e.output)

When I raise my custom SNVUpdateError, I am getting the newlines printing out as \ns.

If I try:except the SVNUpdateError, I can pretty-print the line, but it comes out as stdout, and passes on to the next block of code. I would like to raise the exception, bail out of the task altogether, and print the results from the SVN client as to why things went south without newline and other special characters.

Thanks.

  • 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-08T08:19:09+00:00Added an answer on June 8, 2026 at 8:19 am

    Since your using Python 2.x:

    # Usually a simpler error message without newlines
    print >>sys.stderr, e.message
    # If your message is overly complex, with newlines -- pick a line to print and process it
    #print >>sys.stderr, e.message.split('\n')[-1].strip()
    # Kill the process
    sys.exit(1)
    

    That will print the message (with restricted newlines in the commented print statement) to stderr and kill the process.

    EDIT

    If the string has actual “\\n” characters instead of special character “\n” in the string (which means someone most likely has a type somewhere in string creation), you could do a simple string replacement before printing:

    print >>sys.stderr, malformatedStr.replace("\\n", "\n")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am grabbing a JSON response from AJAX request, the output is something like
Grabbing delimited dates from database and adding new ones to the list, then want
I'm grabbing a list of events from a database and am trying to associate
I'm grabbing an ISBN from the user. Probably from a barcode scanner (EAN 18
I'm grabbing lines from a text file and sifting line by line using regular
Basically, I'm grabbing contents from a PHP file. I check it every 5 seconds.
I have been messing around with HtmlUnit for a little bit and particularly this
We have a ftp system setup to monitor/download from remote ftp servers that are
Hopefully I'm just missing something and this is simple... I have a page that
I do not have a %CLASSPATH% set up. As I understand, this should not

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.