Changes

Created page with "{{Template: Networking_rutos_manual_fw_disclosure | fw_version ={{Template: Networking_rutos_manual_latest_fw | series = {{{series}}} | name = {{{name}}} }} }} ==Summary..."
{{Template: Networking_rutos_manual_fw_disclosure
| fw_version ={{Template: Networking_rutos_manual_latest_fw
| series = {{{series}}}
| name = {{{name}}}
}}
}}

==Summary==

<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:
<ul>
<li>cgitb</li>
<li>email</li>
<li>codecs</li>
<li>distutils</li>
<li>cgi</li>
<li>asyncio</li>
<li>pydoc</li>
<li>ncurses (curses)</li>
<li>decimal</li>
<li>unittest</li>
<li>xml</li>
<li>readline</li>
<li>openssl (ssl)</li>
<li>urllib</li>
<li>multiprocessing</li>
<li>logging</li>
<li>sqlite3</li>
</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>

==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 <b>python <python_file></b> and replace <b><python_file></b> with the relative or absolute path to the Python script or program file.

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

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

<pre>
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!
>>>
</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.

<pre>
root@Teltonika-RUTXXX:~# python --help
</pre>

<pre>
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>
</pre>

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

<pre>
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:~#
</pre>

<pre>
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:~#
</pre>

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