Pages

Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Sunday, September 3, 2023

Fedora 39 : Issues in Fedora with PyGobject and sway-tests.

Today I wanted to test this repo named sway-tests.
I followed the steps there and received an error from gi.repository.
This error is related to another issue related to PyGobject.
In Fedora Linux distro, installing PyGobject is done with pip like this:
$ pip install PyGobject
In order to have no errors, the dnf or dnf5 tool should be used like this ...
I tested the functionality of this installation with a simple example:
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
It worked very well.
After solving this issue, I returned to the initial one and tested the sway-tests.
$ whereis sway
$ env/bin/pytest --sway=/usr/bin/sway
$ sudo env/bin/pytest --sway=/usr/bin/sway
I used the command both with and without sudo.
Both generated the same errors.
For the following command I had to install ... xorg-x11-server-Xephyr:
Xephyr is an X server which has been implemented as an ordinary X application. It runs in a window just like other X applications, but it is an X server ...
... the fixed centered black window specific to the xorg runtime appeared and somewhere on the side the terminal showed me a bunch of errors.
... obviously, I don't know how well sway-tests is implemented, now it's an archived repo, but I solved the use of PyGobject in python on the Fedora linux distribution.

Thursday, July 21, 2022

Fedora 36 : first steps with the Hy.

Hy is a dialect of the Lisp programming language designed to interact with Python by translating s-expressions into Python's abstract syntax tree (AST). Hy was introduced at Python Conference (PyCon) 2013 by Paul Tagliamonte.
This is quite similar to the old GIMP Script Fu that I've worked with in the past. The syntax assumes a join like tabs in HTML, only we'll use parentheses. I haven't studied in detail the implications it has with the python language, but it certainly wasn't invented for nothing.
First, you need to install it with the pip tool.
[mythcat@fedora ~]$ pip3 install hy --user
Collecting hy
...
Successfully built hy
Installing collected packages: funcparserlib, colorama, hy
Successfully installed colorama-0.4.5 funcparserlib-1.0.0 hy-0.24.0
The I test some examples:
[mythcat@fedora ~]$ hy
Hy 0.24.0 using CPython(main) 3.10.5 on Linux
=> (setv a 1)
=> "hello world"
"hello world"
=> (setv mylist [1 2 3])

=> (get mylist 0)
1
=> (defn greet [name]
...  "Hello "
...  (print "Hello " name))
=> (greet "mythcat")
Hello  mythcat
You can test it online with this online tool:

Sunday, December 26, 2021

Fedora 35 : Python and Flask-Mailing on Fedora.

First of all, a Merry Christmas to the users and the Fedora team. Python version 3.10.1 works very well on Fedore 35 and today I tested a packet called: Flask_Mailing.
Flask-Mailing adds SMTP mail sending to your Flask applications., see the Github repo.
Let's start with the installation of this packet with the pip utility.
[mythcat@fedora ~]$ pip install -U flask-mailing
Defaulting to user installation because normal site-packages is not writeable
Collecting flask-mailing
  Downloading Flask_Mailing-0.0.5-py3-none-any.whl (15 kB)
...
Installing collected packages: rfc3986, anyio, typing-extensions, httpcore, dnspython, async-timeout, pydantic, httpx, 
email-validator, blinker, asgiref, aiosmtplib, aioredis, flask-mailing
    Running setup.py install for blinker ... done
Successfully installed aioredis-2.0.0 aiosmtplib-1.1.6 anyio-3.4.0 asgiref-3.4.1 async-timeout-4.0.2 blinker-1.4 dnspython-2.1.0
email-validator-1.1.3 flask-mailing-0.0.5 httpcore-0.14.3 httpx-0.21.1 pydantic-1.8.2 rfc3986-1.5.0 typing-extensions-4.0.1
I create a folder named ExempleFlask001:
[mythcat@fedora ~]$ mkdir ExempleFlask001
[mythcat@fedora ~]$ cd ExempleFlask001/
[mythcat@fedora ExempleFlask001]$ vi flask001.py
I created the simplest example to test through the import procedure and then read with the dir function, here is the source code:
from flask import Flask
from flask_mailing import Mail, Message

app = Flask(__name__)
@app.route("/")
def index():
    test = str(dir(Mail))
    return test
if __name__ == "__main__":
    app.run(debug=True)
The result of running the script on the command line:
[mythcat@fedora ExempleFlask001]$ python flask001.py
 * Serving Flask app 'flask001' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 319-368-265
 ...
The browser's response to the script is this:

Saturday, November 6, 2021

Fedora 35 : PyQt6 and Python 3.

I tested the new python version 10 and pyqt version 6 on the fedora version 35 distribution.
[mythcat@fedora ~]$ python
Python 3.10.0 (default, Oct  4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
...
[mythcat@fedora ~]$ uname -a
Linux fedora 5.14.15-300.fc35.x86_64 #1 SMP Wed Oct 27 15:53:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
I install PyQt6 easy with pip tool:

[mythcat@fedora ~]$ pip install PyQt6 --user
Collecting PyQt6
  Downloading PyQt6-6.2.1-cp36-abi3-manylinux1_x86_64.whl (7.7 MB)
  ...
  Downloading PyQt6_Qt6-6.2.1-py3-none-manylinux_2_28_x86_64.whl (50.0 MB)
  ...
  Downloading PyQt6_sip-13.1.0-cp310-cp310-manylinux1_x86_64.whl (309 kB)
Installing collected packages: PyQt6-sip, PyQt6-Qt6, PyQt6
Successfully installed PyQt6-6.2.1 PyQt6-Qt6-6.2.1 PyQt6-sip-13.1.0
I tested with this python source code and it works fine.
import sys
from PyQt6.QtWidgets import QApplication, QWidget

def main():

    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 200)
    w.move(300, 300)

    w.setWindowTitle('Simple')
    w.show()

    sys.exit(app.exec())

if __name__ == '__main__':
    main()

Tuesday, July 6, 2021

Fedora 34 : Can be better? part 019.

Another way to improve the Fedora 34 is to add the lastes PyQt6 python package into repo.
[root@desk mythcat]# dnf search PyQt6
Last metadata expiration check: 2:03:10 ago on Tue 06 Jul 2021 08:52:41 PM EEST.
No matches found. 
First stable release for PyQt6 was on Jan 2021 by Riverbank Computing Ltd. under GPL or commercial and can be used with Python 3.
Let's install with pip tool:
[mythcat@desk ~]$ /usr/bin/python3 -m pip install --upgrade pip
...
  WARNING: The scripts pip, pip3 and pip3.9 are installed in '/home/mythcat/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, 
  use --no-warn-script-location.
Successfully installed pip-21.1.3
[mythcat@desk ~]$ pip install PyQt6 --user
...
Let's see a simple example with this python package:
import sys
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QLabel

def main():
    app = QApplication(sys.argv)
    win = QLabel()
    win.resize(640, 498)
    win.setText("Qt is awesome!!!")
    win.show()
    app.exec()

if __name__ == "__main__":
    main()
I tested and run well.

Tuesday, April 13, 2021

Fedora 33 : First steps with manim.

Manim is an engine for precise programmatic animations, designed for creating explanatory math videos like 3Blue1Brown
The documentation can be found on this webpage
First, install with the DNF tool all packages:
[root@desk manim_Projects]# dnf install cairo-devel pango-devel ffmpeg python3-devel 
texlive-scheme-medium texlive-standalone.noarch texlive-collection-latexextra.noarch

Last metadata expiration check: 2:19:22 ago on Tue 13 Apr 2021 08:20:03 PM EEST.
Package cairo-devel-1.16.0-9.fc33.x86_64 is already installed.
Package pango-devel-1.48.4-1.fc33.x86_64 is already installed.
Package ffmpeg-4.3.2-2.fc33.x86_64 is already installed.
Package python3-devel-3.9.2-1.fc33.x86_64 is already installed.
Package texlive-scheme-medium-9:svn54074-35.fc33.noarch is already installed.
Package texlive-standalone-9:svn47136-35.fc33.noarch is already installed.
Package texlive-collection-latexextra-9:svn54851-35.fc33.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Use pip tool to install manim and manimlib.
[mythcat@desk manim_Projects]$ pip install manim
...
[mythcat@desk manim_Projects]$ pip install manimlib
...
You can use --user option argument. A default example from the doc area can be a good test.
from manim import * 

config.background_color = DARK_GRAY
class MovingFrame(Scene):
     def construct(self):
        # Write equations
        equation = MathTex("2x^2-5x+2", "=", "(x-2)(2x-1)")

        # Create animation
        self.play(Write(equation))

        # Add moving frames
        framebox1 = SurroundingRectangle(equation[0], buff=.1)
        framebox2 = SurroundingRectangle(equation[2], buff=.1)

        # Create animations
        self.play(Create(framebox1))  # creating the frame

        self.wait()
        # replace frame 1 with frame 2
        self.play(ReplacementTransform(framebox1, framebox2))
    
        self.wait()
I run it well:
[mythcat@desk manim_Projects]$ /home/mythcat/.local/bin/manim -pl -ql -i follow_me_textxt.py 
This is the result:

Saturday, November 7, 2020

Fedora 33 : Install PyGame 2.0 on Fedora.

Today I will show you how to install the python PyGame version 2.0 package with python version 3.9 in Fedora 33 distro. Let's install all Fedora packages need for this python package:
[root@desk pygame]# dnf install SDL2-devel.x86_64 
...
Installed:
  SDL2-devel-2.0.12-4.fc33.x86_64                                               

Complete!
[root@desk pygame]# dnf install SDL2_ttf-devel.x86_64
...
Installed:
  SDL2_ttf-2.0.15-6.fc33.x86_64       SDL2_ttf-devel-2.0.15-6.fc33.x86_64      

Complete!
[root@desk pygame]# dnf install SDL2_image-devel.x86_64
...
Installed:
  SDL2_image-2.0.5-5.fc33.x86_64      SDL2_image-devel-2.0.5-5.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_mixer-devel.x86_64 
...
Installed:
  SDL2_mixer-2.0.4-7.fc33.x86_64      SDL2_mixer-devel-2.0.4-7.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_gfx-devel.x86_64 
...
Installed:
  SDL2_gfx-1.0.4-3.fc33.x86_64        SDL2_gfx-devel-1.0.4-3.fc33.x86_64       

Complete!
[root@desk pygame]# dnf install portmidi-devel.x86_64 
...
Installed:
  portmidi-devel-217-38.fc33.x86_64                                             

Complete!
Use this command to clone it from GitHub and install it:
[mythcat@desk ~]$ git clone https://github.com/pygame/pygame
Cloning into 'pygame'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 38509 (delta 0), reused 0 (delta 0), pack-reused 38505
Receiving objects: 100% (38509/38509), 17.78 MiB | 11.66 MiB/s, done.
Resolving deltas: 100% (29718/29718), done.
[mythcat@desk ~]$ cd pygame/
[mythcat@desk pygame]$ python3.9 setup.py install --user


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...


Hunting dependencies...
SDL     : found 2.0.12
FONT    : found
IMAGE   : found
MIXER   : found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
FREETYPE: found 23.4.17

If you get compiler errors during install, double-check
the compiler flags in the "Setup" file.
...
copying docs/pygame_tiny.gif -> build/bdist.linux-x86_64/egg/pygame/docs
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
creating /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Extracting pygame-2.0.1.dev1-py3.9-linux-x86_64.egg to /home/mythcat/.local/lib/python3.9/site-packages
Adding pygame 2.0.1.dev1 to easy-install.pth file

Installed /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Processing dependencies for pygame==2.0.1.dev1
Finished processing dependencies for pygame==2.0.1.dev1
Let's test it:
[mythcat@desk pygame]$ ls
build	     dist  examples	    README.rst	setup.cfg  src_c   test
buildconfig  docs  pygame.egg-info  Setup	setup.py   src_py
[mythcat@desk pygame]$ python3.9
Python 3.9.0 (default, Oct  6 2020, 00:00:00) 
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.0.1.dev1 (SDL 2.0.12, python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> 

Tuesday, September 15, 2020

Fedora 32 : Can be better? part 008.

The Fedora development is not very active in the last programming language.
The main reason is the build new packages and put on the repository.
I think this can be improved with a good tool to solve all dependencies and link all into a good package.
Today I tested the new Python version 3.5.10 released on September 5th, 2020.
I download an unzip the archive and I use these commands to build this python version
[mythcat@desk ~]$ cd Python-3.5.10/
[mythcat@desk Python-3.5.10]$ ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.5... no
checking for python3... python3
checking for --enable-universalsdk... no
...
The next command is make:
[mythcat@desk Python-3.5.10]$ make
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
   -Werror=declaration-after-statement   -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o 
./Programs/python.c
...
# On Darwin, always use the python version of the script, the shell
# version doesn't use the compiler customizations that are provided
# in python (_osx_support.py).
if test `uname -s` = Darwin; then \
 cp python-config.py python-config; \
fi
Then I used make test.
[mythcat@desk Python-3.5.10]$ make test
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers

Python build finished successfully!
...
For the last part I used this command:
[mythcat@desk Python-3.5.10]$ sudo make install
...
The result of this is ...
[mythcat@desk Python-3.5.10]$ ls
aclocal.m4     config.sub    Include          Mac              Modules  platform        python            README
build          configure     install-sh       Makefile         Objects  Programs        Python            setup.py
config.guess   configure.ac  Lib              Makefile.pre     Parser   pybuilddir.txt  python-config     Tools
config.log     Doc           libpython3.5m.a  Makefile.pre.in  PC       pyconfig.h      python-config.py
config.status  Grammar       LICENSE          Misc             PCbuild  pyconfig.h.in   python-gdb.py
[mythcat@desk Python-3.5.10]$ ./python 
Python 3.5.10 (default, Sep  6 2020, 22:32:07) 
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
...

Sunday, November 3, 2019

Fedora 30 : Introduction to Qt Designer.

Qt Designer is the Qt tool for designing and building graphical user interfaces (GUIs) with Qt Widgets... see the Qt Designer manual webpage.
[root@desk mythcat]# dnf install qt5-designer.x86_64
...
Installed:
  qt5-designer-5.12.5-1.fc30.x86_64                                             
  qt5-qttools-libs-designercomponents-5.12.5-1.fc30.x86_64                      

Complete!
Let's start this tool with this command:
[mythcat@desk ~]$ designer-qt5 
Follow this video tutorial from my youtube channel:

You can preview your work with Ctrl+R keys.
After you finish with the project then save the file with this name: mytest.ui.
The next command to create your working python file named mytest.py.
Use this command with the -x option creates the main section to the my.py file that will allow us to test quickly whether the GUI looks as we intended.
[mythcat@desk ~]$ pyuic5 -x  mytest.ui -o mytest.py
Now you can run it to see the output:
[mythcat@desk ~]$ python3  mytest.py

Wednesday, October 16, 2019

Fedora 30 : News about python 3.8.0 and install on Linux.

The new release of python development comes today.
You can see on the official webpage the new versions of Python 3.7.5 Oct. 15, 2019 and Python 3.8.0 Oct. 14, 2019.
I wrote about how to install version 3.8.0 on Fedora 30.
See the full tutorial here.

Friday, October 4, 2019

Fedora 30 : A general intro to linux signals with python.

UNIX/Linux systems offer special mechanisms to communicate between each individual process with signals. Let's see these signals:
[mythcat@desk ~]$ kill -l
 1) SIGHUP  2) SIGINT  3) SIGQUIT  4) SIGILL  5) SIGTRAP
 6) SIGABRT  7) SIGBUS  8) SIGFPE  9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
Each signal is represented by an integer value, and the list of signals that are available. This simple python script create a process and print one message. Each process named PID comes with a number.
[mythcat@desk ~]$ cat python3 signal_001.py 
cat: python3: No such file or directory
import os
import sys
import time
print('PID number is:', os.getpid())
while True:
    print('Waiting...')
    time.sleep(6)
[mythcat@desk ~]$ python3 signal_001.py 
PID number is: 2566
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Hangup
The PID process can be kill with this command:
[mythcat@desk ~]$ kill -SIGTERM 2566
Let's see another example that receives the signal we have sent to the process.
import os
import signal
import time

def receiveSignal(signalNumber, frame):
    print('Received:', signalNumber)
    raise SystemExit('Exiting')
    return

if __name__ == '__main__':
    # register the signals to be caught
    signal.signal(signal.SIGHUP, receiveSignal)
    signal.signal(signal.SIGINT, receiveSignal)
    signal.signal(signal.SIGQUIT, receiveSignal)
    signal.signal(signal.SIGILL, receiveSignal)
    signal.signal(signal.SIGTRAP, receiveSignal)
    signal.signal(signal.SIGABRT, receiveSignal)
    signal.signal(signal.SIGBUS, receiveSignal)
    signal.signal(signal.SIGFPE, receiveSignal)
    #signal.signal(signal.SIGKILL, receiveSignal)
    signal.signal(signal.SIGUSR1, receiveSignal)
    signal.signal(signal.SIGSEGV, receiveSignal)
    signal.signal(signal.SIGUSR2, receiveSignal)
    signal.signal(signal.SIGPIPE, receiveSignal)
    signal.signal(signal.SIGALRM, receiveSignal)
    signal.signal(signal.SIGTERM, receiveSignal)
    # register the signal to be caught
    signal.signal(signal.SIGUSR1, receiveSignal)

    # register the signal to be ignored
    signal.signal(signal.SIGINT, signal.SIG_IGN)

    # output current process id
    print('My PID is:', os.getpid())

    signal.pause()
Let't run it and see what happend when send a signal to the PID:
[mythcat@desk ~]$ python3 py_pid.py
My PID is: 2698
Received: 10
Exiting
You can see the kill command will send this output: Received: 10 Exiting .
[mythcat@desk ~]$ kill -SIGUSR1 2698

Monday, July 8, 2019

Fedora 30 : Using the python-wikitcms.

This python module named python-wikitcms can be used for interacting with the Fedora wiki.
The Fedora wiki used Fedora's Wikitcms.
Today I test it and works great with Fedora distro version 30.
First, the install of the fedora package with DNF tool:
[root@desk mythcat]# dnf install python3-wikitcms.noarch
...
Downloading Packages:
(1/8): python3-mwclient-0.9.3-3.fc30.noarch.rpm 186 kB/s |  61 kB     00:00    
(2/8): python3-fedfind-4.2.5-1.fc30.noarch.rpm  314 kB/s | 105 kB     00:00    
(3/8): python3-cached_property-1.5.1-3.fc30.noa  41 kB/s |  20 kB     00:00    
(4/8): python3-requests-oauthlib-1.0.0-1.fc29.n 313 kB/s |  40 kB     00:00    
(5/8): python3-jwt-1.7.1-2.fc30.noarch.rpm      112 kB/s |  42 kB     00:00    
(6/8): python3-oauthlib-2.1.0-1.fc29.noarch.rpm 293 kB/s | 153 kB     00:00    
(7/8): python3-simplejson-3.16.0-2.fc30.x86_64. 641 kB/s | 278 kB     00:00    
(8/8): python3-wikitcms-2.4.2-2.fc30.noarch.rpm 264 kB/s |  84 kB     00:00
I used this simple example to get information about the Fedora wiki:
[mythcat@desk ~]$ python3
Python 3.7.3 (default, May 11 2019, 00:38:04) 
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wikitcms.wiki import Wiki
>>> my_site = Wiki()
>>> event = my_site.current_event
>>> print(event.version)
31 Rawhide 20190704.n.1
>>> page = my_site.get_validation_page('Installation','23','Final','RC10')
>>> for row in page.get_resultrows():
...     print(row.testcase)
... 
QA:Testcase_Mediakit_Checksums
QA:Testcase_Mediakit_ISO_Size
QA:Testcase_Mediakit_Repoclosure
QA:Testcase_Mediakit_FileConflicts
QA:Testcase_Boot_default_install
...
>>> dir(my_site)
I used this source code to login with my account.
>>> my_site.login()
A webpage is open to get access to the account and show this info:
The OpenID Connect client Wiki Test Control Management System is asking to authorize access for mythcat. this allow you to access it 
After I agree with this the page tells me to close it:
You can close this window and return to the CLI
The next examples show you how to get and show information from the wiki:
>>> print(my_site.username)
Mythcat
>>> result = my_site.api('query', titles='Mythcat')
>>> for page in result['query']['pages'].values():
...             print(page['title'])
... 
Mythcat
>>> for my_contributions in my_site.usercontributions('Mythcat'):
...     print(my_contributions)
...
This python module comes with low documentation.

Sunday, June 30, 2019

Fedora 30 : The Pythonic tool.

The tutorial for today is about Pythonic tool.
Named Pythonic is a graphical programming tool that makes it easy for users to create Python applications using ready-made function modules.
This tool providing the consistent features and characteristics of a trading bot with just a few clicks.
The Pythonic tool is currently available in four languages: English, German, Spanish, and Chinese. 
The tool comes with basic functions such as a scheduler, if-branches, connectivity, and logging functions are available out of the box and can be parameterized using a corresponding GUI.
Each graphical element is functionally processed individually.
The base idea is: A unique graphical input mask to carry out the parameterization necessary for processing, then after a process completes successfully, the returned result can be transferred to a subsequent process for further use.
You can use server processes can be placed in parallel in the background as listener applications that wait for external events and initiate the creation of a process when the event arrives.
Pythonic's data type list makes it easy to utilize different access techniques (push, pop, insert, append).
The install of this tool is easy on Fedora 30 distro:
[mythcat@desk ~]$ python3.7 -m pip install Pythonic --user
Collecting Pythonic
...
Successfully installed PyQt5-5.8.2 Pythonic-0.12 pandas-0.24.2 pythonic-binance-0.7.2
This is a screenshot with this tool.

Tuesday, April 9, 2019

Fedora 29 : Thonny editor for python.

This Python IDE for beginners named Thonny is a simple editor with Python 3.7 built in.
The official webpage can be found here and the GitHub project page is this.
The development team is from the University of Tartu, Estonia with the help from the open-source community. Thonny grew up in University of Tartu (https://www.ut.ee), Institute of Computer Science (https://www.cs.ut.ee).
I test it today with Fedora 29 and works well.
Let's start with the first step:
[mythcat@desk ~]$ pip3 install thonny --user
Collecting thonny
...
Successfully installed astroid-2.2.5 asttokens-1.1.13 docutils-0.14 isort-4.3.17 jedi-0.13.3 lazy-object-proxy-1.3.1 
mccabe-0.6.1 mypy-0.700 mypy-extensions-0.4.1 parso-0.4.0 pylint-2.3.1 pyperclip-1.7.0 pyserial-3.4 thonny-3.1.2 
typed-ast-1.3.1
...
[root@desk mythcat]# dnf install python3-tkinter.x86_64
Last metadata expiration check: 0:21:20 ago on Tue 09 Apr 2019 09:57:24 PM EEST.

Installed:
  python3-tkinter-3.7.2-5.fc29.x86_64          tk-1:8.6.8-1.fc29.x86_64         

Complete!
This editor can be found on Fedora repo, but I used the last released version software.
[root@desk mythcat]# dnf search thonny
Last metadata expiration check: 0:36:55 ago on Tue 09 Apr 2019 09:57:24 PM EEST.
========================= Name Exactly Matched: thonny =========================
thonny.noarch : Python IDE for beginners

Thursday, March 21, 2019

Fedora 29 : Testing the dnf python module.

Today we tested with Fedora 29 a python module called DNF.
All users have used this tool.
This python module is not very documented on the internet.
A more complex example can be found on DNF tool documentation.
I tried to see what I can get from this module.
Let's start installing it with the pip tool:
$ pip install dnf --user
Here are some tests that I managed to run in the python shell.
[mythcat@desk ~]$ python
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import dnf
>>> dir(dnf)
['Base', 'Plugin', 'VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__path__', '__version__', 'base', 'callback', 'cli', 'comps', 'conf', 'const', 'crypto', 'db', 
'dnf', 'dnssec', 'drpm', 'exceptions', 'goal', 'history', 'i18n', 'lock', 'logging', 'match_counter',
 'module', 'package', 'persistor', 'plugin', 'pycomp', 'query', 'repo', 'repodict', 'rpm', 'sack',
 'selector', 'subject', 'transaction', 'unicode_literals', 'util', 'warnings', 'yum']
>>> import dnf.conf
>>> print(dnf.conf.Conf())
[main]
assumeno: 0
assumeyes: 0
autocheck_running_kernel: 1
bandwidth: 0
best: 0
...
>>> import dnf.module
>>> import dnf.rpm
>>> import dnf.cli
>>> base = dnf.Base()
>>> base.update_cache()
True
This read all repositories:

>>> base.read_all_repos()
You need to read the sack for querying:

>>> base.fill_sack()

>>> base.sack_activation = True
Create a query to matches all packages in sack:

>>> qr=base.sack.query() 
Get only available packages:

>>> qa=qr.available() 
Get only installed packages:

>>> qi=qr.installed()
>>> q_a=qa.run()
>>> for pkg in qi.run():
...     if pkg not in q_a:
...             print('%s.%s' % (pkg.name, pkg.arch))
... 
NetworkManager-openvpn.x86_64
NetworkManager-openvpn-gnome.x86_64
coolkey.x86_64
glibc-debuginfo.x86_64
glibc-debuginfo-common.x86_64
kernel.x86_64
kernel.x86_64
kernel-core.x86_64
kernel-core.x86_64
Get all packages installed on Linux:

>>> q_i=qi.run()
>>> for pkg in qi.run():
...     print('%s.%s' % (pkg.name, pkg.arch))
You can see more about the Python programming language on my blog.

Thursday, January 24, 2019

Fedora 29 : Selinux and python.

Today I tested the selinux python module with Fedora 29.
The wikipedia page comes with this intro about SELinux: Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls (MAC). ... A Linux kernel integrating SELinux enforces mandatory access control policies that confine user programs and system services, as well as access to files and network resources.

This kernel module can help you with security the network and running application on your Linux.
This very complex kernel module can be used with your policy configuration files designed to fix your security issues.
First, the install is easy to do with the dnf tool:
[root@desk mythcat]# dnf install python2-libselinux.x86_64 
Last metadata expiration check: 1:31:46 ago on Thu 24 Jan 2019 07:04:16 AM EET.
Dependencies resolved.
...
Installed:
  python2-libselinux-2.8-6.fc29.x86_64                                          

Complete!
I tested this python module with a few simple examples:
[mythcat@desk ~]$ python 
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import selinux
>>> selinux.is_selinux_enabled()
1
>>> selinux.lgetfilecon_raw(".bashrc")
[37, 'unconfined_u:object_r:user_home_t:s0']
>>> selinux.lgetfilecon_raw(".bashrc")
[37, 'unconfined_u:object_r:user_home_t:s0']
>>> selinux.selinux_getpolicytype()[1]
'targeted'
>>> selinux.selinux_getpolicytype()
[0, 'targeted']

Wednesday, December 12, 2018

Fedora 29 : Using pytorch on Fedora distro.

The goal of this tutorial is about how to install and start using the pytorch python module.
Another part is to show tensors without using matplotlib python module.
The reason I wrote this simple tutorial and not on my python blogger is Fedora distro.
The python module named pytorch is based on Torch, used for applications such as natural language processing.
The installation of pytorch into many operating systems can be tricky.
Let's start this tutorial using GitHub clone commands:
[mythcat@desk ~]$  git clone --recursive https://github.com/pytorch/pytorch
...
running install_scripts
Installing convert-caffe2-to-onnx script to /home/mythcat/.local/bin
Installing convert-onnx-to-caffe2 script to /home/mythcat/.local/bin
Using this commands un Fedora linux shell will install easy this python module:
[mythcat@desk ~]$  cd pytorch/
[mythcat@desk ~]$ pip install typing
[mythcat@desk ~]$ python setup.py install --user
[mythcat@desk ~]$ pip install torchvision --user
Collecting torchvision
...
You cannot use the pytorch into pytorch folder.
[mythcat@desk pytorch]$ cd ..
[mythcat@desk ~]$ python -c "import torch; print(torch.__version__)"
1.0.0a0+bf1d411
The result of this output is not an common error. You can fix if you set the paths for pytorch installation. Let's test the pytorch installation:
[mythcat@desk ~]$ python
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch 
>>> import torchvision
>>> import torchvision.dataset as datasets
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named dataset
>>> import torchvision.datasets as datasets
>>> print(dir(torch))
['Argument', 'ArgumentSpec', 'Block', 'BoolType', 'ByteStorage', 'ByteTensor', 'CharStorage', 'CharTensor', 'Code', 
'CompleteArgumentSpec', 'DoubleStorage', 'DoubleTensor', 'DynamicType', 'ExecutionPlanState', 'FatalError', 'FloatStorage',
 'FloatTensor', 'FloatType', 'FunctionSchema', 'Future', 'Generator', 'Gradient', 'Graph', 'GraphExecutor', 
'GraphExecutorState', 'HalfStorage', 'HalfStorageBase', 'HalfTensor', 'IODescriptor', 'IntStorage', 'IntTensor', 'IntType',
 'JITException', 'ListType',
...
>>> print(dir(datasets))
['CIFAR10', 'CIFAR100', 'CocoCaptions', 'CocoDetection', 'DatasetFolder', 'EMNIST', 'FakeData', 'FashionMNIST', 
'ImageFolder', 'LSUN', 'LSUNClass', 'MNIST', 'Omniglot', 'PhotoTour', 'SEMEION', 'STL10', 'SVHN', '__all__', 
'__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'cifar', 'coco', 'fakedata', 
'folder', 'lsun', 'mnist', 'omniglot', 'phototour', 'semeion', 'stl10', 'svhn', 'utils']
>>> x = torch.rand(76)
>>> x.size()
>>> print(x)
tensor([0.9839, 0.5844, 0.4347, 0.5883, 0.1383, 0.7701, 0.1879, 0.5604, 0.4486,
        0.6782, 0.5038, 0.1078, 0.1244, 0.0996, 0.0230, 0.5457, 0.8903, 0.7732,
        0.9948, 0.3201, 0.3149, 0.7180, 0.8811, 0.4468, 0.8169, 0.2998, 0.3900,
        0.8067, 0.0090, 0.6006, 0.8385, 0.8786, 0.3652, 0.5630, 0.1407, 0.7747,
        0.5734, 0.4998, 0.4056, 0.7473, 0.2797, 0.8852, 0.3563, 0.9421, 0.1136,
        0.7676, 0.4224, 0.4350, 0.4968, 0.4457, 0.3047, 0.6792, 0.1026, 0.3593,
        0.4147, 0.6517, 0.5916, 0.3567, 0.8584, 0.9421, 0.2091, 0.6339, 0.5428,
        0.3811, 0.9310, 0.8856, 0.0770, 0.7920, 0.4860, 0.4276, 0.4780, 0.8627,
        0.7287, 0.4340, 0.2859, 0.2213])
>>> from PIL import Image
>>> logo = np.array(Image.open('logo.png').resize((512,512)))
>>> logo_tensor = torch.from_numpy(logo)
>>> logo_tensor.size()
(512, 512, 4)
>>> img = Image.fromarray(logo)
>>> img.show()

Monday, October 1, 2018

Fedora 28 : Web development with Nikola and python.

The development team comes with this info about Nikola:
Nikola is a static site and blog generator, written in Python. It can use Mako and Jinja2 templates, and input in many popular markup formats, such as reStructuredText and Markdown — and can even turn Jupyter Notebooks into blog posts! It also supports image galleries and is multilingual. Nikola is flexible, and page builds are extremely fast, courtesy of do it (which is rebuilding only what has been changed).
I tested today with Fedora 28 and python version 2.7.15.
If you take a look at Nikola handbook, you will see all the features, options and settings you need for web development.
The installation is very simple:
[mythcat@desk ~]$ pip install Nikola --user
Collecting Nikola
...
Installing collected packages: Nikola
Successfully installed Nikola-7.8.15

[mythcat@desk ~]$ nikola init mysite
[2018-10-01T14:09:02Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2018-10-01T14:09:02Z] WARNING: bundles: Setting USE_BUNDLES to False.
Creating Nikola Site
====================

This is Nikola v7.8.15.  We will now ask you a few easy questions about your new site.
If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.
--- Questions about the site ---
Site title [My Nikola Site]: my_website
Site author [Nikola Tesla]: catafest
Site author's e-mail [n.tesla@example.com]: catafest@yahoo.com
Site description [This is a demo site for Nikola.]: website with Nikola static sit
Site URL [https://example.com/]: http://example.com
    The URL does not end in '/' -- adding it.
Enable pretty URLs (/page/ instead of /page.html) that don't need web server configuration? [Y/n] y
--- Questions about languages and locales ---
We will now ask you to provide the list of languages you want to use.
Please list all the desired languages, comma-separated, using ISO 639-1 codes.  
The first language will be used as the default.
Type '?' (a question mark, sans quotes) to list available languages.
Language(s) to use [en]: en

Please choose the correct time zone for your blog. Nikola uses the tz database.
You can find your time zone here:
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Time zone [Europe/Bucharest]: 
    Current time in Europe/Bucharest: 17:12:36
Use this time zone? [Y/n] y
--- Questions about comments ---
You can configure comments now.  Type '?' (a question mark, sans quotes) to list available comment systems.  
If you do not want any comments, just leave the field blank.
Comment system: 

That's it, Nikola is now configured.  Make sure to edit conf.py to your liking.
If you are looking for themes and addons, check out https://themes.getnikola.com/ and https://plugins.getnikola.com/.
Have fun!
[2018-10-01T14:12:54Z] INFO: init: Created empty site at mysite.
Now you can build and start the server with this command:
[mythcat@desk ~]$ cd mysite/
[mythcat@desk mysite]$ ls
cache  conf.py  conf.pyc  files  galleries  listings  pages  posts
[mythcat@desk mysite]$ nikola build
[2018-10-01T14:14:51Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2018-10-01T14:14:51Z] WARNING: bundles: Setting USE_BUNDLES to False.
Scanning posts........done!
.  render_posts:timeline_changes
...
[2018-10-01T14:14:52Z] WARNING: Nikola: Python 2 is old and busted. Python 3 is the new hotness.
[2018-10-01T14:14:52Z] WARNING: Nikola: Nikola is going to deprecate Python 2 support in 2017. You already have Python 3
available in your system. Why not switch?

Please check http://bit.ly/1FKEsiX for details.

.  sitemap:output/sitemap.xml
.  sitemap:output/sitemapindex.xml
.  robots_file:output/robots.txt
[mythcat@desk mysite]$ nikola serve -b 
Let's see the result of this running server:
To add a post just use this command:
[mythcat@desk mysite]$ nikola new_post
[2018-10-01T14:16:09Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2018-10-01T14:16:09Z] WARNING: bundles: Setting USE_BUNDLES to False.
Creating New Post
-----------------

Title: New post
Scanning posts........done!
[2018-10-01T14:16:24Z] INFO: new_post: Your post's text is at: posts/new-post.rst

[mythcat@desk mysite]$ nikola build
[2018-10-01T14:16:34Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2018-10-01T14:16:34Z] WARNING: bundles: Setting USE_BUNDLES to False.
Scanning posts........done!
.  render_posts:timeline_changes
The result will be this:

There are a few themes for Nikola available at the Themes Index.
[mythcat@desk mysite]$ nikola theme -l
[2018-10-01T14:21:20Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2018-10-01T14:21:20Z] WARNING: bundles: Setting USE_BUNDLES to False.
Available Themes:
-----------------
blogtxt
bnw
bootblog
bootblog-jinja
bootstrap
bootstrap-jinja
bootstrap3-gradients
bootstrap3-gradients-jinja
cadair
canterville
carpet
detox
foundation6
hack
hemingway
hpstr
hyde
jidn
lanyon
libretto
lotabout
material-theme
maupassant
mdl
monospace
oldfashioned
planetoid
readable
reveal
reveal-jinja
slidemenu
srcco.de
yesplease
zen
zen-forkawesome
zen-ipython
zen-jinja

Sunday, September 23, 2018

Fedora 28 : Start a service daemon with Python.

In this tutorial I will starting one service using systemctl , python and systemd. First, you need to create a file named testpython.service .
[mythcat@desk system]# cd /etc/systemd/system/
[root@desk system]# vim testpython.service
This file is a configuration file for this service.
[Unit]
Description=Python Service
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/python /home/mythcat/test_service.py
[Install]
WantedBy=multi-user.target
Create the python file for this service. I named test_service.py .
[root@desk system]# exit
exit
[mythcat@desk system]$ cd ~
[mythcat@desk ~]$ vim test_service.py

#!/usr/bin/env python

import logging
import time

logging.basicConfig(level="INFO")

while True:
    logging.info("Hi")
    time.sleep(3)
Change permissions file for this python file and testpython.service, see:
[mythcat@desk ~]$ chmod 764 test_service.py
Because you run this service with systemd then selinux will send you error, fix that:
[mythcat@desk ~]$ chcon -t bin_t ~/test_service.py
Reload all services and start your service with this commands:
[root@desk system]# systemctl daemon-reload
[root@desk system]# systemctl start  testpython.service
[root@desk system]# systemctl status  testpython.service
● testpython.service - Python Service
   Loaded: loaded (/etc/systemd/system/testpython.service; enabled; vendor>
   Active: active (running) since Sat 2018-09-22 21:36:23 EEST; 5s ago
 Main PID: 7213 (python)
    Tasks: 1 (limit: 2102)
   Memory: 5.7M
   CGroup: /system.slice/testpython.service
           └─7213 /usr/bin/python /home/mythcat/test_service.py

Sep 22 21:36:23 desk systemd[1]: Started Python Service.
Sep 22 21:36:24 desk python[7213]: INFO:root:Hi
Sep 22 21:36:27 desk python[7213]: INFO:root:Hi
You can use the journalctl command to see the output of this service:
[root@desk system]# journalctl -u testpython.service 
-- Logs begin at Sat 2018-09-22 20:40:06 EEST, end at Sat 2018-09-22 21:31:07 EEST. --
Sep 22 20:40:06 desk python[6232]: INFO:root:Hi
Sep 22 20:40:09 desk python[6232]: INFO:root:Hi
Sep 22 20:40:12 desk python[6232]: INFO:root:Hi
Sep 22 20:40:15 desk python[6232]: INFO:root:Hi
Sep 22 20:40:18 desk python[6232]: INFO:root:Hi
Sep 22 20:40:21 desk python[6232]: INFO:root:Hi
Sep 22 20:40:24 desk python[6232]: INFO:root:Hi
Sep 22 20:40:27 desk python[6232]: INFO:root:Hi
Sep 22 20:40:30 desk python[6232]: INFO:root:Hi
Let's see the result:

Wednesday, September 6, 2017

Fedora 26 : The install of PyCharm IDE .

Today I make a new test with PyCharm IDE for python development on linux.
It video show the installation of PyCharm on the Fedora 26 operating system.
As you know , PyCharm is free, open-source and come with a Lightweight IDE for Community.
You can buy it but you will have the Professional Full-featured IDE.