Author Archives: alesk
IronPython – working with Registry
Here is a code snippet that I wrote recently for IronPython, correcting some registry information that I put by mistake in our image that is used for cloning client PC’s. I’m sure PowerShell script would be even shorter and cleaner, but I had to come with some working code in a hurry.
# -*- coding: cp1250 -*-
# odbc_patch.py -- patching my shallowness
# AlesK.
__about__= "IronPython script // odbc_patch2.py by AlesK"
from Microsoft.Win32 import Registry
# -----------------------------------------------
# How to enumerate a node from ODBC.INI.
# Print System DSN names with SERVER key value if present
# (SERVER key is mandatory for MS ODBC for Oracle, MySQL ODBC,
# etc., but not for Oracle supplied driver!
#
# For complete reference to Regirstry class refer to:
# msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx
# You can use:
# Registry.ClassesRoot|CurrentConfig|CurrentUser|
# LocalMachine|PerformanceData|Users
# ------------------------------------------------
system_dsn = Registry.LocalMachine.OpenSubKey('Software\\ODBC\\ODBC.INI')
for dsn in system_dsn.GetSubKeyNames():
dsn_key = system_dsn.OpenSubKey(dsn)
server = dsn_key.GetValue('SERVER')
# print only those DSN's that were created with MS ODBC)
# and thus have SERVER defined
if server is not None:
print("DSN=" + dsn + " SERVER=" + str(server))
# ------------------------------------------------------
# How to read and change value in registry.
# Registry.GetValue
# Registry.SetValue
#
# The plot: by mistake I added MS at the end of SERVER variable
# for DSN's that are using MS ODBC driver. Instead of
# SERVER = ORAXMS I really want SERVER = ORAX, striping off MS.
# Candidates in my case are: ORAXMS, ORAYMS, ORAZMS.
# ------------------------------------------------------
odbc_dsn = ['ORAXMS','ORAYMS','ORAZMS']
odbc_node = "HKEY_LOCAL_MACHINE\\Software\\ODBC\\ODBC.INI"
odbc_key = "SERVER"
for dsn in odbc_dsn:
value = ''
value = Registry.GetValue(odbc_node + '\\' + dsn, odbc_key, value)
if value in odbc_dsn:
Registry.SetValue(odbc_node + '\\' + dsn, odbc_key, dsn.strip('MS'))
print("ODBC.INI: patched " + dsn + " SERVER=" + dsn +
" to SERVER=" + dsn.strip('MS'))
else:
print("ODBC.INI: " + dsn + " - nothing to patch.")
Sample output:
C:\Scripts\IronPython\Registry>ipy odbc_patch2.py
DSN=ORAXMS SERVER=ORAXMS
DSN=ORAYMS SERVER=ORAYMS
DSN=ORAZMS SERVER=ORAZMS
DSN=ORA6MS SERVER=ORAT
ODBC.INI: patched ORAXMS SERVER=ORAXMS to SERVER=ORAX
ODBC.INI: patched ORAYMS SERVER=ORAYMS to SERVER=ORAY
ODBC.INI: patched ORAZMS SERVER=ORAZMS to SERVER=ORAZ
DBGWPROC.DLL on Windows 2008 R2 (Windows 7 x64)
We have a custom built client/server application developed in VisualBasic 6. VB 6 is unsupported development/deployment environment since March 2005. Recently, I stumbled on a bug with library DBGWPROC.DLL while trying to install client part of application on Windows 7 x64 (as far as I can tell, this error is related to x64 version of Windows 7/2008R2). Here is a recipe which I used to overcome the installation error:
- Author released the library to public domain, so get the newest release from here, more precisely from here.
- unzip library to C:\Windows\SysWOW64
- execute library registration at command line:
cmd> cd C:\Windows\SysWOW64 cmd> regsvr32 DbgWproc.dll
If you’re doing registration on Windows 2008 R2 SP1 registration should succeed without the error, if you’re doing registration on Windows 7 x64 SP1, you’ll likely receive an error but you can ignore it (at least in my case everything worked as expected afterwards.Your millage can vary!)!
- install your application that is using DBGWPROC.DLL from your msi, when you receive error regarding DBGWPROC.DLL, simply ignore it.
- Test the application. Mine worked as if it was installed on Windows XP.
Bozos at work

Marketing bozos at Oracle struck again, with so called “study report” done this time by ORCInternational, titled “Database Manageability and Productivity Cost Comparison Study: Oracle Database 11g Release 2 vs. IBM DB2 9.7”. It’s interesting that they came to the same percent savings (43%) as Edison group who published similar (if not exact) pamphlet in 2009.
Nevertheless, that “oracle red color” in all table headers looks very nice, Big Boss must be very happy with this report!
The last time marketing bozos at Oracle published report that “proved” that Oracle11g saves 41% DBA costs compared with MS SQL Server 2008. This time around, study (again) confirms that:
Quote: Study Confirms Oracle Saves 43 Percent More DBA Time Than DB2.
ORC International interviewed Oracle and DB2 database administrators (DBAs) and IT architects; then ran tests to measure DBA daily routines and tasks. Their comparison revealed significant time and resource savings when using Oracle Database 11g over IBM DB2 9.7, including productivity savings of more than US$51,000 per DBA annually.
What a pity that saving is 43% and not 42%, at least we should be laughing with a good reason.
Installing OracleXE 11.2 on OpenSUSE 11.4
Until now, I was trying to avoid SUSE/OpenSUSE Linux distros for reasons that goes beyond technology. I must say OpenSUSE pleasantly surprised me with the installation process. Little that I can complain about. Of course, installing Oracle XE 11.2 (beta) was my first post-installation step:
$ cd Downloads $ wget http://ftp.novell.com/partners/oracle/sles-11/orarun-1.9-172.20.21.54.x86_64.rpm [->Download Oracle XE 11.2 Beta into "Downloads" directory from otn.oracle.com.] $ unzip linux.x64_11gR2_OracleXE.zip Check if bc (GNU command line calculator) is installed and if it's not install it: $ sudo zypper install bc then it's as easy as: $ sudo zypper install oracle-xe-11.2.0-0.5.x86_64.rpm $ sudo zypper install orarun-1.9-172.20.21.54.x86_64.rpm $ su - # /etc/init.d/oracle-xe configure # exit $ nano $HOME/.bashrc and add line at the end of file: . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
Optionally, you can configure Apex. You’ll find shorcut “Get Started with Oracle Database 11g Express edition” in Application panel. Don’t forget to turn off firewall (or better yet configure firewall to allow access to 8080 or whatever port you chose).
If you want to add your account to dba group that’ll allow you to connect “/ as sysdba” without a password, then:
$ su - # usermod -a -G dba alesk
Wake-On-Lan with Python 3.x
In addition to PowerShell Wake-On-LAN script example I found example that works with python 3.x in ActiveState Code recipes collection:
#!/usr/bin/env python
# wol.py
#
# This module is from ActiveState Code Recipes:
# http://code.activestate.com/recipes/358449-wake-on-lan/
# and patched for Python 3 with:
# http://code.activestate.com/recipes/577609-wake-on-lan-for-python-3/
#
# Example:
# import wol
# wol.wake_on_lan('70:F3:95:15:00:B5')
#
import socket
import struct
def wake_on_lan(macaddress):
""" Switches on remote computers using WOL. """
# Check macaddress format and try to compensate
if len(macaddress) == 12:
pass
elif len(macaddress) == 12 + 5:
sep = macaddress[2]
macaddress = macaddress.replace(sep,'')
else:
raise ValueError('Incorrect MAC address format')
# Pad the synchronization stream
data = b'FFFFFFFFFFFF' + (macaddress * 20).encode()
send_data = b''
# Split up the hex values in pack
for i in range(0, len(data), 2):
send_data += struct.pack('B', int(data[i: i + 2], 16))
# Broadcast it to the LAN
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(send_data, ('255.255.255.255',7))
You must be logged in to post a comment.