wooey / Wooey

A Django app that creates automatic web UIs for Python scripts.
http://wooey.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.13k stars 184 forks source link

Can't add script without argument #293

Closed adnan-alam closed 5 years ago

adnan-alam commented 5 years ago

I want to add script that don't require any type of argument to be passed by the user. But failed to add this type of script. A sample of script is given below:

import pandas as pd 

print("Hello World")

try:
    df = pd.DataFrame()
    li = [{"Name":  "Adnan Alam", "Age":  23}, {"Name": "Test User", "Age": 30}]
    df = df.append(li)
    df.to_csv("test_csv.csv", index=False)
except Exception as e:
    print(e)

I'm getting this error when try to add this script:

ParserError at /admin/wooey/script/add/

No exception message supplied
Chris7 commented 5 years ago

You'll need to wrap the script using argparse, as currently there is no title/description/etc. to keep track of for versions. This can be simple as:

import argparse
parser = argparse.ArgumentParser('My cool script')
def main():
  your_stuff_here

if __name__ == '__main__':
  main()

(I wrote that in github's editor, so workable code is a maybe, but that's the idea. Let me know if this helps.

adnan-alam commented 5 years ago

Thanks, it worked !