Python Forum
Code used to work 100%, now sometimes works!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code used to work 100%, now sometimes works!
#5
I updated that section of the code so that I would at least get error codes, and using a different mechanism to run the commands.

def MoveFile(pFile, pDest):
    isFile = os.path.isfile(pFile)
    if isFile == True:
        dPath=os.path.dirname(pDest)
        isDir = os.path.isdir(dPath)
        if isDir == False:
            CreateFolder(dPath)
        
        os.system('move "%s" "%s"' % (pFile, pDest))
        #shutil.move(pFile, pDest)
        WriteLog("Moved: '%s' to '%s'" % (pFile, pDest))
        
        if right(pDest, 3) == "mpg":
            time.sleep(5)
            #BEGIN CCEXTRATOR
            ccCmnd = [ccPath, "-delay",  "0", pDest]
            WriteLog ("BEGIN: Closed Captions Extraction on %s: %s" % (pDest, ccCmnd))
            ccErrCode = subprocess.run(ccCmnd)
            if str(ccErrCode.returncode) == "0":
                WriteLog ("SUCCESS!! - Closed Captions")
            else:
                WriteLog ("ERROR!! - Closed Captions failed with the following: %s" % ccErrCode)
            #END CCEXTRATOR    
            
            #COMSKIP
            WriteLog ("BEGIN: Comskip on %s" % pDest)
            csErrCode = subprocess.run([csPath, "--ini=" + BasePath + "Comskip/comskip.ini", pDest])
            
            if str(csErrCode.returncode) == "0" or str(csErrCode.returncode) == "1":
                WriteLog ("SUCCESS!! - Comskip")
            else: 
                WriteLog ("ERROR!! - Comskip failed with the following: %s." % str(csErrCode))
            #END COMSKIP
    else:
        WriteLog("Info: '%s' is not a file, so won't be moved." % pDest)
Reply


Messages In This Thread
RE: Code used to work 100%, now sometimes works! - by muzicman0 - Jan-10-2023, 11:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  hi need help to make this code work correctly atulkul1985 5 851 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,142 Nov-15-2023, 06:56 PM
Last Post: jst
  newbie question - can't make code work tronic72 2 732 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Code works but doesn't give the right results colin_dent 2 761 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Beginner: Code not work when longer list raiviscoding 2 864 May-19-2023, 11:19 AM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,896 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 938 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Something the code dont work AlexPython 13 2,349 Oct-17-2022, 08:34 PM
Last Post: AlexPython
  cannot get code to work Led_Zeppelin 10 2,526 Jun-30-2022, 06:28 PM
Last Post: deanhystad
  How does this code work? pd_minh12 3 1,386 Apr-15-2022, 02:50 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020