Finally, a small project for the development of the Django Project was completed today, using Python to write an automated on-line project. Used to Python3.5,django 1.11.2,ansible,centos7.
The functions are described as follows:
1. Use the Web page to click on the project to be launched
2. Browser waits for background command call during background system execution
3, after the completion of the implementation of the background to upload the results back to the browser.
Step Explanation:
1, in Django to distinguish between the GET and post request way
2, use subprocess. Popen called when StdOut is a byes type requires a type conversion using str (stdout,encoding= ' utf-8 '), using ansible for the underlying remote command execution. You can also wear an HTML vest like a ansible command line.
3, use <pre>{{executing_processes}}</pre> to show the output when using HTML display to return content, if the return is garbled description stdout not do character encoding. Because the python3.5 version is used.
4. Use shell command nohup python manages.py runserver 0.0.0.0:8000 & command to execute in background.
Page Show:
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/99/78/wKiom1lIwgOC2yVZAABsUNGgiII485.jpg-wh_500x0-wm_ 3-wmp_4-s_2497090651.jpg "title=" 2017-06-20_143334.jpg "alt=" Wkiom1liwgoc2yvzaabsunggiii485.jpg-wh_50 "/>
Select the item to be launched
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/99/78/wKiom1lIwlOSv0weAACFvZOceC0100.jpg-wh_500x0-wm_ 3-wmp_4-s_3226965950.jpg "title=" 2017-06-20_143317.jpg "alt=" Wkiom1liwlosv0weaacfvzocec0100.jpg-wh_50 "/>
Return to execution results
Writing this blog post is a record of your own in Python development, ready to shift from an OPS engineer to a DevOps engineer.
Finally, attach the code
This article is from the "Learning Exchange" blog, please be sure to keep this source http://725689.blog.51cto.com/715689/1940200
Use Python to write the script automatically and return the results to HTML