MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Archive for February, 2017

Install EasyGUI on Fedora

without comments

The EasyGUI library is a nice tool for developing GUI applications. It doesn’t require you to know event-driven programming to write basic GUI applications because it’s based on Python functions.

You can download and install the EasyGUI library with yum utility like this:

yum install -y python-easygui

It should generate the following list:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  | 2.8 kB  00:00     
Resolving Dependencies
--> Running transaction check
---> Package python-easygui.noarch 0:0.96-7.fc20 will be installed
--> Processing Dependency: tkinter for package: python-easygui-0.96-7.fc20.noarch
--> Processing Dependency: python-setuptools for package: python-easygui-0.96-7.fc20.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:1.4.2-1.fc20 will be installed
---> Package tkinter.x86_64 0:2.7.5-16.fc20 will be installed
--> Processing Dependency: libtk8.5.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Processing Dependency: libtcl8.5.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Processing Dependency: libTix.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Running transaction check
---> Package tcl.x86_64 1:8.5.14-1.fc20 will be installed
---> Package tix.x86_64 1:8.4.3-11.fc20 will be installed
---> Package tk.x86_64 1:8.5.14-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch         Version               Repository     Size
================================================================================
Installing:
 python-easygui          noarch       0.96-7.fc20           fedora        481 k
Installing for dependencies:
 python-setuptools       noarch       1.4.2-1.fc20          updates       413 k
 tcl                     x86_64       1:8.5.14-1.fc20       fedora        1.9 M
 tix                     x86_64       1:8.4.3-11.fc20       fedora        253 k
 tk                      x86_64       1:8.5.14-1.fc20       fedora        1.4 M
 tkinter                 x86_64       2.7.5-16.fc20         updates       316 k
 
Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)
 
Total download size: 4.7 M
Installed size: 13 M
Downloading packages:
(1/6): python-setuptools-1.4.2-1.fc20.noarch.rpm            | 413 kB  00:00     
(2/6): python-easygui-0.96-7.fc20.noarch.rpm                | 481 kB  00:00     
(3/6): tkinter-2.7.5-16.fc20.x86_64.rpm                     | 316 kB  00:00     
(4/6): tix-8.4.3-11.fc20.x86_64.rpm                         | 253 kB  00:01     
(5/6): tcl-8.5.14-1.fc20.x86_64.rpm                         | 1.9 MB  00:01     
(6/6): tk-8.5.14-1.fc20.x86_64.rpm                          | 1.4 MB  00:03     
--------------------------------------------------------------------------------
Total                                              1.5 MB/s | 4.7 MB  00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : 1:tcl-8.5.14-1.fc20.x86_64                                   1/6 
  Installing : 1:tk-8.5.14-1.fc20.x86_64                                    2/6 
  Installing : 1:tix-8.4.3-11.fc20.x86_64                                   3/6 
  Installing : tkinter-2.7.5-16.fc20.x86_64                                 4/6 
  Installing : python-setuptools-1.4.2-1.fc20.noarch                        5/6 
  Installing : python-easygui-0.96-7.fc20.noarch                            6/6 
  Verifying  : 1:tk-8.5.14-1.fc20.x86_64                                    1/6 
  Verifying  : tkinter-2.7.5-16.fc20.x86_64                                 2/6 
  Verifying  : 1:tix-8.4.3-11.fc20.x86_64                                   3/6 
  Verifying  : 1:tcl-8.5.14-1.fc20.x86_64                                   4/6 
  Verifying  : python-easygui-0.96-7.fc20.noarch                            5/6 
  Verifying  : python-setuptools-1.4.2-1.fc20.noarch                        6/6 
 
Installed:
  python-easygui.noarch 0:0.96-7.fc20                                           
 
Dependency Installed:
  python-setuptools.noarch 0:1.4.2-1.fc20       tcl.x86_64 1:8.5.14-1.fc20      
  tix.x86_64 1:8.4.3-11.fc20                    tk.x86_64 1:8.5.14-1.fc20       
  tkinter.x86_64 0:2.7.5-16.fc20               
 
Complete!

You can then test the EasyGUI library with the following three lines of code inside the IDLE interpreter:

Python 2.7.5 (default, Apr 10 2015, 08:09:05) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import easygui
>>> flavor = easygui.enterbox("What flavor of bum do you like?")
>>> if easygui.msgbox("You like " + flavor + " gum.") == 'OK':
...   print "OK button clicked ..."
... 
OK button clicked ...

The easygui.enterbox call displays the image below. Enter “Peppermint” in the entry box and click the OK button to assign the “Peppermint” string literal to the flavor variable.

The easygui.msgbox call displays the message below:

When you click the OK button, the program returns an “OK” string to the Python code. It prints the string “OK button clicked …” string:

As always, I hope this helps those looking for instructions and a quick way to play with Python and GUI applications.

Written by maclochlainn

February 22nd, 2017 at 1:35 am

Reset Oracle Password

without comments

This blog entry shows you how to reset the system password for an Oracle Database. It uses a Linux image running Oracle Database 11g Express Edition. It assumes the student user is the sudoer user.

After you sign on to the student user account, you open a Terminal session and you should see the following:

[student@localhost python]$

The oracle user account should be configured to prevent a login. So, you should use the su command or sudo command to open a terminal shell as the root user.

[student@localhost python]$ sudo sh
[sudo] password for student:

As the root user, you can login as the oracle user with the following command:

su - oracle

and, you should see the following prompt. You can see the present working directory (pwd) with the pwd command:

-bash-4.2$ pwd
/u01/app/oracle

You need to source the oracle_env.sh shell file created by the installation of the Oracle Database during the installation. You have two approaches to source the environment file, the first approach is with a dot (.), like

. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

or, this

source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

The oracle_env.sh file contains the following:

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export PATH=$ORACLE_HOME/bin:$PATH

Now, you can connect to the Oracle Database as the internal user with the following command:

sqlplus / as sysdba

Once connected as the internal user, you can reset the system user’s password to “cangetin” with this command:

ALTER USER system IDENTIFIED BY cangetin;

At this point, you can also stop and start the database. You stop the database with this command:

shutdown immediate

You can then start the database with this command:

startup

After setting the system user password, sign out of SQL*Plus. Then, you can type two exits to return to the student user account, like this:

-bash-4.2$ exit
logout
sh-4.2# exit
exit
[student@localhost python]$

As always, I hope this helps those who need to reset the system password when they don’t know what it was to begin with.

Written by maclochlainn

February 21st, 2017 at 3:45 pm