I have this python program that accepts a date and checks if the input date is greater then 180 days from the current date. This program works fine when I call it from the interpreter.
I am using a third party program that uses python scripts. As I understand it passes arguments as dictionaries, so the only difference I am aware of is how I retrieve my arguments (arg.get('ret')). Can anyone see a problem with this code?
CODE
def diff(arg=""):
"""Accepts a date and return days between current date """
if( arg == ""):
return {'ret': "Input date String"}
else:
import datetime
now = datetime.date.today()
input = arg.get('ret').split("/")
input = datetime.date(int(input[2]),int(input[0]),int(input[1]))
change = datetime.timedelta(180)
result = now - input
if(result > change):
return "false"
else:
return "true"
This is the error I am receiving when trying to test the script in my 3rd party program.
Arguments: {'ret': '9/27/2008'}
Error Line: 6
Traceback (innermost last):
File "./scripts/diff.py", line 6, in diff
The 3rd party program is written in Java btw.
Thanks!
This post has been edited by Novast11: 31 Aug, 2009 - 10:47 AM