Hello All,

I'm getting some odd results when using a RunScript Condition for the "Script.ReturnValue = 1" and wanted to have another set of eyes look at it. I have a dummy test at the very beginning of the script that I copied from the forums to force a True result and it will not return True, only keeps running through the rest of the script. I do get my ShowMessage pop-ups though to tell me of the condition results. Look for the code directly after the line "# Force test for True".

I forgot to mention that I added a secondary RunScript condition, but only containing the dummy test lines and it worked, but I have no idea why it will not work in the full script below. My question is for understanding purposes, as it should return true no matter what scenario. Also, I have not run this live, only through the debugger, if that makes a difference.

The script is coded in Python and it works with the rest of my conditioning, but I'm totally baffled why the dummy True test is not returning. Thoughts?

In a nutshell, the script is looking for mostly empty pages that only contain control characters like "\n", etc., that are the results of a Splitter. I'm still testing this, so it's not complete. Long story based on a recent finding and this script will help me figure out what is really happening on our HUGE workflow.

Code:
import os
import string

# Get PPWatch Job Filename
jfn = Watch.GetJobFileName()
ofn = Watch.GetOriginalFileName()

Watch.ShowMessage("The job filename is: " + jfn)
Watch.ShowMessage("The original filename is: " + ofn)

# Force test for True
everythingOK = True
Watch.ShowMessage("eOK value: \"{0}\".".format(everythingOK))
if (everythingOK):
    Watch.ShowMessage("eOK If Test True!")
    Script.ReturnValue = 1
else:
    Watch.ShowMessage("eOK If Test False!")
    Script.ReturnValue = 0

# Get file size
filsize = os.path.getsize(jfn)
filtype = type(filsize)
Watch.ShowMessage("File size is: \"{0}\".".format(filsize))
Watch.ShowMessage("filsize type = \"{0}\".".format(filtype))

# Check for file sizes greater than 100b
if (filsize < 100):
    Watch.ShowMessage("Filesize is less than 100b: \"{0}\".".format(filsize))
    Watch.Log("LOG: File is less than 100 bytes!  Do not process!", 2)
    Script.ReturnValue = 1
else:
    Watch.ShowMessage("Filesize is greater than 100b: \"{0}\".".format(filsize))

with open(jfn, 'r') as myfile:
    prtdata = myfile.read()
    #Test for printable character (whitespace is considered printable)
    printable_char_test = all(c in string.printable for c in prtdata)
    count = 0
    for char in prtdata:
        count += 1

    #Test for file character length
    if (count <= 10):
        Watch.ShowMessage("Character count is <= 10: \"{0}\".".format(count))
        Watch.Log("LOG: File contains less than 10 characters!  Do not process!", 2)
        Script.ReturnValue = 1
    else:
        Watch.ShowMessage("Character count is > 10: \"{0}\".".format(count))
        Script.ReturnValue = 0



Secondary Questions:
Also, is Python v3 supported with PlanetPress Suite 7? I'm still running v2.7 on our server, but I'm planning a server upgrade next year.

Is Windows Server 2016 supported for PP Suite 7 too? I'll only saw Server 2012 R2 listed on a recent update specs listing, but no mention of Server 2016. Same question for PP Connect? I'll eventually make that leap.

Thank you.


Edited by Ken Stulce (09/22/17 11:51 AM)
_________________________
-------------------
Ken Stulce
Manager of Application Development
Essex Industries, Inc.
-------------------