Script which only runs in Windows

al at servana.com al at servana.com
Mon Jun 26 16:05:43 EDT 2000


Hello.

We have an odd problem with Python which we cannot resolve.

Below, is a script we have been running in Win32 for months.

We moved our scripts from Win32 to Slackware Linux and IF statements 
which
are not in functions or classes will cause errors when you
try to run the script.

I have had retyped the script thinking it was the tab/space
issue, but nothing changes - in Linux we cannot use IF outside
a function or CLASS for some reason.

We are posting this here as it seems very serious and we were hoping 
someone else had seen the problem.

-----------------------------------------
import os
import sys
import time
import string
import sugdb
import gadfly

sBillDir = "dirname"
sSugLogin = "login"
sSugPWord = "password"
sSugSite = "171.1.1.1"

#
# The following Dirs MUST end in a path slash
#
SOutputDir = "/home/DATA/"
sDBLocation = "/usr/local/bin/db/"

#
# The script is called without any passin values.
#
# It starts by getting the date and extrapolating strings to use for 
file
# dates
#
# Next, the FTPASGET script is called and its return value is checked
#
# If all was well, then the DB processing script is called
#

#
# The following declarations are very important.
# This reads the date and creates the strings for the following
#

iTime = time.time()

# This is the format string for the date of the files we need to look 
for (like: 06/09)
sFileTime = time.strftime("%m/%d", time.localtime(iTime))
sFileName = time.strftime("%m%d", time.localtime(iTime))
sDirTime = time.strftime("%d%b", time.localtime(iTime))
sDateStart = time.strftime("%m-%d-%y", time.localtime(iTime))
sProcStart = time.strftime("%H:%M:%S", time.localtime(iTime))

#
# here is where we do some work
#
try:
    sResult = os.system('python ftpasget.py -q -g * -d ' + sFileTime 
+ ' -l ' + sSugLogin + ' -p ' + sSugPWord + ' ' + sSugSite + ' ' + 
sBillDir + ' ' + sOutputDir + sDirTime)
except:
    sGetMinutes = 0

iCurrTime = time.time()

#
# PROBLEM: The following will fail unless in a function 
# The failure error is:
#      Name Error: sResult
#
if sResult == 0:
    sGetMinutes = (iCurrTime - iTime) / 60
else:
    sGetMinutes = 0

iTime = iCurrTime

------------------------------------
If we run the code in Win32, or from a function in Linux, it works 
without error.

Any suggestions would be priceless.





More information about the Python-list mailing list