Python Forum
modify script. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: modify script. (/thread-22598.html)

Pages: 1 2


RE: modify script. - MuhammadTalha - Nov-21-2019

cannot stat '_ph0/pb.dvscf1': no such file or directory
this error generates


RE: modify script. - Gribouillis - Nov-21-2019

I'd like to know where the error happened in your script. For this you can add the following file os2.py in the same directory as your script, and at the top of your script, you replace import os with import os2 as os,
then run your script and report the whole error traceback here again.
# os2.py

from os import *
import subprocess as sp

class CommandFailed(Exception):
    pass

def system(command):
    try:
        retcode = sp.call(command, shell=True)
        if retcode < 0:
            raise CommandFailed(
                ('Command was terminated by signal', -retcode, 'Command was', command))
        elif retcode:
            raise CommandFailed(
                ('Command failed with return code', retcode, 'Command was', command))
        return retcode
    except OSError as e:
        raise CommandFailed(
            ('Command failed with OSError', e.args, e.filename, e, 'Command was', command))



RE: modify script. - MuhammadTalha - Nov-23-2019

hi Gribouillis ,
this error generated ,
Error:
cp: cannot stat '_ph0/diam.dvscf1': No such file or directory cp: cannot stat '_ph0/diam.phsave': No such file or directory cp: cannot stat '_ph0/diam.q_2/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_2/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_3/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_3/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_4/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_4/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_5/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_5/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_6/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_6/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_7/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_7/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_8/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_8/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_9/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_9/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_10/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_10/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_11/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_11/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_12/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_12/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_13/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_13/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_14/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_14/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_15/diam.dvscf1': No such file or directory rm: cannot remove '_ph0/diam.q_15/*wfc*': No such file or directory cp: cannot stat '_ph0/diam.q_16/diam.dvscf1': No such file or directory



RE: modify script. - Gribouillis - Nov-23-2019

Normally python prints exactly where the error occurs in the python script. This is the useful part. This is what my code was supposed to show.


RE: modify script. - DeaD_EyE - Nov-23-2019

(Nov-23-2019, 06:45 AM)Gribouillis Wrote: Normally python prints exactly where the error occurs in the python script. This is the useful part. This is what my code was supposed to show.

It can't, because this program is calling for everything extensively rm and cp.
The error came from rm and cp itself, but the program has no clue about Python.
So it can't give the expected output. If the creator has used Python-Functions instead of os tools, the code will
be much denser and lesser.


RE: modify script. - Gribouillis - Nov-23-2019

DeaD_EyE Wrote:It can't
It can if you catch the return code of the command as I suggested above.