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)

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:

  1. ALLUSERS=””: It specifies per-user installation context
  2. ALLUSERS=1: It specifies per-machine installation context
  3. 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
  1. Windows 7: Uses the MSIINSTALLPERUSER property to specify the installation context.

i. MSIINSTALLPERUSER ="": Per-Machine installation.

ii. MSIINSTALLPERUSER =1: Per-User installation

  1. 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.
  2. Windows XP: Set Windows Installer performs a per-user installation if the user has user access privileges.
  3. 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:

  1. 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.

  1. 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.

QA: MSI Interview: Explain the difference between Property and PROPERTY


Q: Explain the difference between Property and PROPERTY

ANS:

  1. Public Property:

Public properties can be changed anytime by a user, system or admin on the command line while installing, by applying a transform or by interacting with the authored user interface (Installation Interface)

They are always in upper case

  1. Private Property:

The installer uses then internally and their values are initialized in the installation database (msi) or set by the values determined by the OS.

Private property names must always include lowercase letters. (Thanks Alek for correcting)

Few annoying issues with App-V


Few issues or blocks which I found with App-V are as follows:

  1. If two application (say excel 2007 & Excel 2002) have same file type associations (say .xls) then the last one cached gets the file type associations.
  2. If any office application (say excel.exe) is locally installed and is currently running and is in focus then virtual excel will not launch even if the file type association is set for it.

Python: World Clock


import time
import wx
import wx.gizmos as gizmos
from datetime import datetime
from pytz import timezone
import pytz

utc = pytz.utc
    
class LED_clock(wx.Frame):
    """
    Create nice LED clock showing the current time
    """
    def __init__(self, parent, id):
        pos = wx.DefaultPosition
        wx.Frame.__init__(self, parent, id, title='maya World Clock, Ver: 0.0.1', pos=pos, size=(200, 70))
        self.SetIcon(wx.Icon(r"clock.ico", wx.BITMAP_TYPE_ICO))
        size = wx.DefaultSize
        style = gizmos.LED_ALIGN_CENTER
        self.estLed = gizmos.LEDNumberCtrl(self, -1, pos, size, style)
        self.m_stESTTime = wx.StaticText( self, wx.ID_ANY, u"EST Time", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE|wx.STATIC_BORDER )
        self.m_stESTTime.SetBackgroundColour( wx.Colour( 255, 221, 187 ) )
        bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
        bSizer5 = wx.BoxSizer( wx.VERTICAL )
        bSizer5.Add(self.m_stESTTime, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 0 
        bSizer5.Add(self.estLed, 1, wx.EXPAND, 5 )
        bSizer4.Add(bSizer5, 1, wx.EXPAND, 5 )
        self.m_stIndiaTime = wx.StaticText( self, wx.ID_ANY, u"IST Time", wx.DefaultPosition, wx.DefaultSize,  wx.ALIGN_CENTRE|wx.STATIC_BORDER )
        self.m_stIndiaTime.SetBackgroundColour( wx.Colour( 255, 221, 187 ) )
        self.indiaLed = gizmos.LEDNumberCtrl(self, -1, pos, size, style)
        bSizer1 = wx.BoxSizer( wx.VERTICAL )
        bSizer1.Add(self.m_stIndiaTime , 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALIGN_CENTRE_HORIZONTAL, 5 )
        bSizer1.Add(self.indiaLed, 1, wx.EXPAND, 5 )
        bSizer4.Add(bSizer1, 1, wx.EXPAND, 5 )
        self.SetSizer( bSizer4 )
        self.Layout()
        self.OnTimer(None)
        self.timer = wx.Timer(self, -1)
        self.timer.Start(1000)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.Centre()

    def GetIndiaTime(self):
        fmt = '%H %M %S'
        india = timezone('Asia/Kolkata') #('Asia/Kolkata')
        eastern = timezone('US/Eastern')
        loc_dt = eastern.localize(datetime.now())
        in_dt = loc_dt.astimezone(india)
        return (in_dt.strftime(fmt))

    def OnTimer(self, event):
        current = time.localtime(time.time())
        ts = time.strftime("%H %M %S", current)
        self.estLed.SetValue(ts)
        tst = self.GetIndiaTime()
        self.indiaLed.SetValue(tst)

if __name__ == '__main__':
    app = wx.App()
    frame = LED_clock(None, -1)
    frame.Show(True)
    app.SetTopWindow(frame)
    app.MainLoop()