mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-31 23:24:20 +03:00 
			
		
		
		
	python_examples: Reformatted, self-checking, executable
* Moved body of each python example to main.  This allows for basic
      load module testing for CI
    * General cleanup of python modules (crlf/tabs/prints/etc)
    * Chmod'ed to 755 to allow running examples without specifying the
      python interpreter
    * Added ctest for loading python2/3 modules
    * Added jniclasscode pragma for java swig interface files.
    * Updated check_examplenames.py module to check all languages vs. a
      cxx example name
    * Added tests for checking python module and test loading
    * Added 'make test' to travis-ci run (run ctests)
    * Print a more meaningful message when not building cxx docs into
      python modules
    * Updated check_clean.py to only check java wrapper files
    * ENABLED ctests for UPM
    * Deleted using_carrays.py python example - this is covered by other
      examples
Signed-off-by: Noel Eck <noel.eck@intel.com>
			
			
This commit is contained in:
		
							
								
								
									
										40
									
								
								examples/python/grovescam.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										40
									
								
								examples/python/grovescam.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -25,37 +25,41 @@ | ||||
| import sys | ||||
| import pyupm_grovescam as upmGrovescam | ||||
|  | ||||
| # Instantiate a Grove Serial Camera on UART 0 | ||||
| camera = upmGrovescam.GROVESCAM(0) | ||||
| def main(): | ||||
|     # Instantiate a Grove Serial Camera on UART 0 | ||||
|     camera = upmGrovescam.GROVESCAM(0) | ||||
|  | ||||
| # make sure port is initialized properly. 115200 baud is the default. | ||||
| if (not camera.setupTty()): | ||||
| 	print "Failed to setup tty port parameters" | ||||
| 	sys.exit(1) | ||||
|     # make sure port is initialized properly. 115200 baud is the default. | ||||
|     if (not camera.setupTty()): | ||||
|         print "Failed to setup tty port parameters" | ||||
|         sys.exit(1) | ||||
|  | ||||
| if (camera.init()): | ||||
|     if (camera.init()): | ||||
|         print "Initialized..." | ||||
| else: | ||||
|     else: | ||||
|         print "init() failed" | ||||
|  | ||||
| if (camera.preCapture()): | ||||
|     if (camera.preCapture()): | ||||
|         print "preCapture succeeded..." | ||||
| else: | ||||
|     else: | ||||
|         print "preCapture failed." | ||||
|  | ||||
| if (camera.doCapture()): | ||||
|     if (camera.doCapture()): | ||||
|         print "doCapture succeeded..." | ||||
| else: | ||||
|     else: | ||||
|         print "doCapture failed." | ||||
|  | ||||
| print "Image size is", camera.getImageSize(), "bytes" | ||||
|     print "Image size is", camera.getImageSize(), "bytes" | ||||
|  | ||||
| if (camera.getImageSize() > 0): | ||||
|     if (camera.getImageSize() > 0): | ||||
|         print "Storing image.jpg..." | ||||
|         if (camera.storeImage("image.jpg")): | ||||
|                 print "storeImage succeeded..." | ||||
|             print "storeImage succeeded..." | ||||
|         else: | ||||
|                 print "storeImage failed." | ||||
|             print "storeImage failed." | ||||
|  | ||||
| print "Exiting." | ||||
| sys.exit(0) | ||||
|     print "Exiting." | ||||
|     sys.exit(0) | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     main() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Noel Eck
					Noel Eck