.. NutShell documentation ============== Using NutShell ============== This sections explains how product queries are made from command line, Python code and HTTP requests. Instructions for setting up product generators is explained in :ref:`generators` . .. _command-line-usage: Command-line usage ================== Basic format for all the command line invocations is:: python3 -m nutshell.nutshell By default, NutShell tries to read configuration file ``nutshell.cnf`` in the current directory. A file in other location is given with ``-c `` . Online help is optained with ``-h``:: python3 -m nutshell.nutshell -h Simple query using configuration file and product definition:: python3 -m nutshell.nutshell -c nutshell-demo.cnf demo.image.pattern_WIDTH=300_HEIGHT=200_PATTERN=OCTAGONS.png In the above example, options ``--make`` and ``--product`` are left implicit: making a product is the default action, and free arguments are handled as files ie. product definitions. Other commands .. _nutshell-api: NutShell API ============ Simple example:: from nutshell import nutshell, product # Initialize service server = nutshell.ProductServer('nutshell.cnf') product_info = product.Info(filename = "201708121600_radar.rack.comp_SITES=fikor,fivan,fiika_SIZE=800,800.png" ) # Retrieve / generate a product response = server.make_request(product_info, "MAKE") # Results: print("Return code: {0} ".format(response.returncode)) print("Status (HTTP code): {0}: ".format(response.status)) print("File path: {0} ".format(response.path)) print() # Example: further processing (image data) from PIL import Image file = Image.open(response.path) print(file.info) .. _http-server: NutShell HTTP Server ==================== Java version ------------ Installation:: util/configure.sh tomcat util/install.sh tomcat Python version -------------- This version is for test use only. No specific installation procedure is required, all the required information is in the conf file (nutshell.cnf). The server can be started with:: python3 -m nutshell.httpd or:: python3 -m nutshell.httpd --conf nutshell.cnf The process responses with a line of type: Starting: http://localhost:8088/nutshell/ The port (8088) and prefix ( nutshell/ ) are defined in the conf file. See code documentation: :any:`nutshell.httpd`