Difference between revisions of "Template:Networking rutos manual python"

From Teltonika Networks Wiki
(Created page with "{{Template: Networking_rutos_manual_fw_disclosure | fw_version ={{Template: Networking_rutos_manual_latest_fw | series = {{{series}}} | name = {{{name}}} }} }} ==Summary...")
 
m
Line 10: Line 10:
 
<b>Python</b> is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.
 
<b>Python</b> is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.
  
Teltonika Python3 package has Python version 3.9 and these modules:
+
----
 +
 
 +
This manual page provides an overview of Python functionality in {{{name}}} devices.
 +
 
 +
<b>Note:</b> Python is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.
 +
 
 +
<b>Python3</b> package has Python version 3.9 and these modules:
 
<ul>
 
<ul>
 
   <li>cgitb</li>
 
   <li>cgitb</li>
Line 30: Line 36:
 
   <li>sqlite3</li>
 
   <li>sqlite3</li>
 
</ul>
 
</ul>
 
----
 
 
This manual page provides an overview of Python3 functionality in {{{name}}} devices.
 
 
<b>Note:</b> Python3 is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.
 
  
 
<span style="color:#d33">'''Disclaimer: before installing Python3 package make sure that the target device has a sufficient amount of free storage space!!!'''</span>
 
<span style="color:#d33">'''Disclaimer: before installing Python3 package make sure that the target device has a sufficient amount of free storage space!!!'''</span>
Line 62: Line 62:
 
</pre>
 
</pre>
  
For more information on how to use Python use the command <b>python --help</b> while in the device's CLI and for how to use its interpreter use the command <b>help()</b> when using the Python interpreter interface.
+
For more information on how to use <b>python</b> command use the command <b>python --help</b> while in the device's CLI and for how to use Python interpreter use the command <b>help()</b> when using the Python interpreter interface.
  
 
<pre>
 
<pre>

Revision as of 10:39, 30 March 2023

Template:Networking rutos manual fw disclosure

Summary

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.


This manual page provides an overview of Python functionality in {{{name}}} devices.

Note: Python is additional software that can be installed from the Services → [[{{{name}}} Package Manager|Package Manager]] page.

Python3 package has Python version 3.9 and these modules:

  • cgitb
  • email
  • codecs
  • distutils
  • cgi
  • asyncio
  • pydoc
  • ncurses (curses)
  • decimal
  • unittest
  • xml
  • readline
  • openssl (ssl)
  • urllib
  • multiprocessing
  • logging
  • sqlite3

Disclaimer: before installing Python3 package make sure that the target device has a sufficient amount of free storage space!!!

Python Usage

After installing the package a new command will become available in [[{{{name}}}_CLI|CLI (Command-line interface)]] which enables the device to invoke Python scripts or program files and allows access to the Python interpreter interface.

To invoke a Python script or program file use the command python <python_file> and replace <python_file> with the relative or absolute path to the Python script or program file.

root@Teltonika-RUTXXX:~# python /test_py.py 
Hello world!

Alternatively, using just the command python will let you enter the interpreter and write and execute your code there.

root@Teltonika-RUTXXX:~# python
Python 3.9.7 (default, Mar 23 2023, 08:32:35) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello world!")
Hello world!
>>> 

For more information on how to use python command use the command python --help while in the device's CLI and for how to use Python interpreter use the command help() when using the Python interpreter interface.

root@Teltonika-RUTXXX:~# python --help
root@Teltonika-RUTXXX:~# python
Python 3.9.7 (default, Mar 23 2023, 08:32:35) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 3.9's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/3.9/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help>

To exit the Python interpreter interface and return to device's CLI use the command exit() or quit().

root@Teltonika-RUTXXX:~# python
Python 3.9.7 (default, Mar 23 2023, 08:32:35) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
root@Teltonika-RUTXXX:~#
root@Teltonika-RUTXXX:~# python
Python 3.9.7 (default, Mar 23 2023, 08:32:35) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
root@Teltonika-RUTXXX:~#

[[Category:{{{name}}} Services section]]