Oct-06-2016, 12:03 AM
(This post was last modified: Oct-06-2016, 12:05 AM by Fred Barclay.)
(Oct-05-2016, 08:42 AM)Ofnuts Wrote:(Oct-04-2016, 09:02 PM)snippsat Wrote: You should also use Subprocess it replace use of older os.system().
... and use it to call you srm command directly (ie, without a intermediate shell). Then each of your command parameters is a string in a list and you completely avoid the shell syntax issues.
Hmm... that would be nice but this is what I get when srm-ing /home/fred/Git/test (folder):
Error:/home/fred/Git/test (folder)
Traceback (most recent call last):
File "/home/fred/.local/share/caja-python/extensions/caja-wipe.py", line 112, in wipe_file
subprocess.call([cmd])
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Applicable code is this:def wipe_file(self, menu, file): for filename in filelist: path = pwd+"/"+filename path = str(path) if not os.access(path, os.W_OK): print("You do not have permission to wipe this file") # Debugging return # print(filelist) # Debugging # print(filename) # Debugging print(path) # Debugging cmd = "srm -rv "+path # -v is good for debugging subprocess.call([cmd])If needed, the entire source code is on GitHub:
https://github.com/Fred-Barclay/Caja-Wipe
(Look in src/caja-wipe.py)
Thanks for all help so far!
EDIT: Python 3.4
OS: Arch
Editor: Atom with Material Syntax UI and the Termination terminal plugin
Micah 6:8
Editor: Atom with Material Syntax UI and the Termination terminal plugin
Micah 6:8