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 7909119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:15:59+00:00 2026-06-03T12:15:59+00:00

I try to use Python envoy for better access to Shell programs. But i

  • 0

I try to use Python envoy for better access to Shell programs. But i have a problem that i want to delete all items of a folder, but envoy can’t handle my varaible:

import envoy
import os

# Check for a empty folder. 
if len(os.listdir(csv_save_path)) != 0:
    for item in os.listdir(csv_save_path):
        result = envoy.run('rm -v',item)
        print result.std_out
        print result.std_err

Output:

"rm: missing operand\nTry `rm --help' for more information.\n"

I don’t want use subprocces. Anyone a idea what is wrong?

Edit:

Thank for your quick response. Now i get this error message:

    Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib64/python2.7/site-packages/envoy/core.py", line 40, in target
    bufsize=0,
  File "/usr/lib64/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

*** AttributeError: 'NoneType' object has no attribute 'returncode'

But i check on the path of the file, with and without path, it’s failing.

Edit: The Solution is to use %s to get the item to the right place.

import envoy
import os

# Check for a empty folder. 
if len(os.listdir(csv_save_path)) != 0:
    for item in os.listdir(csv_save_path):
        result = envoy.run('rm -v %s' % item)
        print result.std_out
        print result.std_err

so far

  • 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-03T12:16:03+00:00Added an answer on June 3, 2026 at 12:16 pm

    Try this

    import envoy
    import os
    
    # Check for an empty folder. 
    if len(os.listdir(csv_save_path)) != 0:
        for item in os.listdir(csv_save_path):
            result = envoy.run('rm -v %s' % item)
            print "Output: %s" % result.std_out
            print "Error: %s" % result.std_err
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python
I have some Python code that works correctly when I use python.exe to run
Try to use python-auth2 for my project, but I got: In [1]: import oauth2
At work we have Oracle 7. I would like to use python to access
If I try to use the shell I get this API conflict. /home/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-linux-i686.egg-tmp/_mysql.so:6: RuntimeWarning:
I'm trying to learn python but have some problem running source files from power
Whenever I try to use the python interpreter on windows, C:\path>pythonw.exe cubes.py <blank line>
I try use string as a regular expression pattern but I've following errors PHP
I try to use single quotes as much as possible and I've noticed that
I try to use checkContour() function in new python api (cv2) and it do

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.