################################################################
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
My 2cent tips & tricks on computer technology & Application Virtualization ...
Friday, March 26, 2010
Tips: Python: Switch in Python
################################################################
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
# There is no 'Switch' statement in Python, but we can use the following example to simulate switch case.
# We can use dictionary in python to simulate the switch case
################################################################
def f1():
print("Hello f1")
def f2():
print("Hello f2")
funcdict = {
0: f1,
1: f2
}
selection = 1
funcdict.get(selection)()
Tuesday, March 9, 2010
Tips: Python: How to get the full username in Windows
import win32com,win32com.client,pythoncom
sDomain ="ES"
sUser ="johrim"
sADSPath= sDomain + sUser
oUser=win32com.client.GetObject("WinNT://%s,user" % sADSPath )
print (oUser.FullName)
Monday, March 8, 2010
Tips: VBScript: Get Full NT User Name using VBScript
Set oNetwork = CreateObject("WScript.Network")
sDomain = "test"
sUser = "johri"
sADSPath= sDomain & "/" & sUser
Set oUser = GetObject("WinNT://" & sADSPath & ",user")
WScript.Echo oUser.FullName
sDomain = "test"
sUser = "johri"
sADSPath= sDomain & "/" & sUser
Set oUser = GetObject("WinNT://" & sADSPath & ",user")
WScript.Echo oUser.FullName
Saturday, March 6, 2010
Tips: Python : wxFormBuilder v3.1.67-beta (Febuary 18, 2010) Python Update
Latest version of wxFormBuilder does not support wxAdditions fully, thus I have updated few XML files to support FlatNotebook & wx.propgrid widgets.
I did not tried to update these files for other widgets but it should be similar.
- Download wx.propgrid and install it.
- Download the XML.Zip folder and extract it in plugins\wxAdditions\xml folder.
- Restart the wxformbuilder.
I did not tried to update these files for other widgets but it should be similar.
Thursday, February 25, 2010
Tips: Video: convert mov to avi file using ffmpeg
Use the following command to convert .mov file to .avi file.
ffmpeg -i file-name.mov -g 60 -vcodec msmpeg4v2 -acodec pcm_u8 -f avi file-name.avi
Friday, February 19, 2010
Tips: MSI: Save differences between two msi as MST file using ruby & python
Ruby
Python
require 'win32ole'
msiClass = WIN32OLE.new("WindowsInstaller.Installer")
msidb = msiClass.OpenDatabase("C:\\temp\\MountPointGenerator.msi",0)
newmsidb = msiClass.OpenDatabase("C:\\temp\\updatedMountPointGenerator.msi",0)
transform = newmsidb.GenerateTransform(msidb,"c:\\temp\\newtest.mst")
Python
import win32com.client
import os
import sys
msiOpenDatabaseModeReadOnly=0
msidb=r"c:\temp\MountPointGenerator.msi"
msiupdb=r"c:\temp\updatedMountPointGenerator.msi"
mstdb=r"C:\temp\MNPtrans.mst"
installer = win32com.client.Dispatch("WindowsInstaller.Installer")
database = installer.OpenDatabase(msidb, msiOpenDatabaseModeReadOnly)
updatedDB= installer.OpenDatabase(msiupdb , msiOpenDatabaseModeReadOnly)
updatedDB.GenerateTransform(database, mstdb)
Labels:
Development,
Installation,
MSI,
Python,
ruby,
Tips
Wednesday, January 27, 2010
TIPS: SQLite: Python: How to get the details of a table
There are two ways you can achieve it.
1.
cursor.execute("PRAGMA table_info(tablename)")
print cursor.fetchall()
2.
sql = sqlite3.connect(self.cFile)
c = sql.cursor()
query = "select * from preferences"
c.execute(query)
col = [tuple[0] for tuple in c.description]
print col
Note:
cur.description returns a tuple of information about each table. The entire tuple is : (name, type_code, display_size, internal_size, precision, scale, null_ok)
1.
cursor.execute("PRAGMA table_info(tablename)")
print cursor.fetchall()
2.
sql = sqlite3.connect(self.cFile)
c = sql.cursor()
query = "select * from preferences"
c.execute(query)
col = [tuple[0] for tuple in c.description]
print col
Note:
cur.description returns a tuple of information about each table. The entire tuple is : (name, type_code, display_size, internal_size, precision, scale, null_ok)
Wednesday, January 20, 2010
TIPS: Google Chrome offline installer
Use the following link to install Google Chrome offline installer.
http://www.google.com/chrome/eula.html?standalone=1
http://www.google.com/chrome/eula.html?standalone=1
Tuesday, January 19, 2010
TIPS: OpenOffice->Impress: How to apply an image to the background of a Presentation
- Go to View > Master > Slide Master
- Right click on the slide and choose Slide > Set Background Picture for Slide....
- Select the desired Image and
- Switch off master view.
Friday, January 8, 2010
QA: MSI Interview: What is the difference between installations using ALLUSERS="", ALLUSERS=1 and ALLUSERS=2 option?
Q: What is the difference between installations using ALLUSERS=””, ALLUSERS=1 and ALLUSERS=2 option?
ANS:
i. MSIINSTALLPERUSER ="": Per-Machine installation.
ii. MSIINSTALLPERUSER =1: Per-User installation
ANS:
- ALLUSERS=””: It specifies per-user installation context
- ALLUSERS=1: It specifies per-machine installation context
- ALLUSERS=2: It enables the system to define the values of ALLUSERS, and in turn the installation context, dependent upon the user’s privileges and the version of Windows
- Windows 7: Uses the MSIINSTALLPERUSER property to specify the installation context.
i. MSIINSTALLPERUSER ="": Per-Machine installation.
ii. MSIINSTALLPERUSER =1: Per-User installation
- Windows Vista: Windows Installer complies with User Account Control (UAC). If the user has user access privileges, and ALLUSERS=2, the installer performs a per-machine installation only if Admin credentials are provided to the UAC dialog box. If UAC is enabled and the correct Admin credentials are not provided, the installation fails with an error stating that administrator privileges are required. If UAC is disabled by the registry key, group policy, or the control panel, the UAC dialog box is not displayed and the installation fails with an error stating that administrator privileges are required.
- Windows XP: Set Windows Installer performs a per-user installation if the user has user access privileges.
- Windows 2000: Windows Installer performs a per-machine installation if the user has administrative access privileges on the computer. If the user does not have administrative access privileges, Windows Installer resets the value of the ALLUSERS property to an empty string ("") and performs a per-user installation.
QA: MSI Interview : What are the ADDLOCAL and ADDSOURCE properties?
Q: What are the ADDLOCAL and ADDSOURCE properties?
Ans:
It is the property which contains the list of features, delimited by commas (,), which are to be installed locally. These features must be present in the Feature column of the Feature Table.
It is the property which contains the list of features, delimited by commas (,), which are to be installed to run from the Source. These features must be present in the Feature column of the Feature Table.
Ans:
- ADDLOCAL:
It is the property which contains the list of features, delimited by commas (,), which are to be installed locally. These features must be present in the Feature column of the Feature Table.
- ADDSOURCE:
It is the property which contains the list of features, delimited by commas (,), which are to be installed to run from the Source. These features must be present in the Feature column of the Feature Table.
Subscribe to:
Posts (Atom)