~ Mayank Johri's Tips ~

January 27, 2010

TIPS: SQLite: Python: How to get the details of a table

Filed under: Uncategorized — mayankjohri @ 4:41 am
Tags: ,

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)

January 20, 2010

TIPS: Google Chrome offline installer

Filed under: Uncategorized — mayankjohri @ 12:44 pm

Use the following link to install Google Chrome offline installer.

http://www.google.com/chrome/eula.html?standalone=1

January 19, 2010

TIPS: OpenOffice->Impress: How to apply an image to the background of a Presentation

Filed under: Uncategorized — mayankjohri @ 11:04 am
  1. Go to View > Master > Slide Master
  2. Right click on the slide and choose Slide > Set Background Picture for Slide….
  3. Select the desired Image and
  4. Switch off master view.

January 8, 2010

QA: MSI Interview: What is the difference between installations using ALLUSERS=”", ALLUSERS=1 and ALLUSERS=2 option?

Filed under: Uncategorized — mayankjohri @ 1:35 pm

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?

Filed under: Uncategorized — mayankjohri @ 1:10 pm

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

Filed under: Uncategorized — mayankjohri @ 12:32 pm

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.

They are always in lower case.

January 6, 2010

Few annoying issues with App-V

Filed under: Uncategorized — mayankjohri @ 1:45 pm

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.

January 1, 2010

Python: World Clock

Filed under: Python — mayankjohri @ 3:48 am

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()

November 12, 2009

Tips: Free audio books

Filed under: Tips — mayankjohri @ 7:44 am
Tags: ,

November 6, 2009

More App-V Interview Questions

  1. Why the Flag files in OSD Scripts should be saved in Virtual File System instead of Physical System
  2. How to create default.sprj file.

November 4, 2009

FAQ: Ruby GEM error: ERROR: While executing gem … (URI::InvalidURIError)

Filed under: Uncategorized — mayankjohri @ 11:27 am
Tags: , ,

set the http_proxy system variable as
set http_proxy=http://proxy.mj.com:8080
instead of
set http_proxy=proxy.mj.com:8080

October 27, 2009

App-V Interview Questions

  1. What is App-V Sequencing
  2. What is VFS Sequenging
  3. What is MNT Sequencing
  4. What is SystemGuard
  5. What are the protocols supported for streamming
  6. What is active upgrade
  7. Which applications can be sequenced.
  8. How to manage exclusion list
  9. Can network shortcut applications be sequenced
  10. Can host files be sequenced
  11. Define the normal upgrade process
  12. What precausions are needed while sequencing
  13. How reboots are handled while sequencing
  14. Can all types of services be sequenced
  15. Why application is launched more then once while sequencing.
  16. How much disk space is required on sequencing machine
  17. Which hardware component be updated to get better performance in sequencing process.
  18. What is a suite and how we can create them
  19. What is the difference between update and active upgrade
  20. What is the difference between suite and dynamic suite
  21. Why only Q drive is necessary for sequncing can we have any other also.
  22. Name few disadvantages of using SCCM server for deploying App-V Applications
  23. Name few advantages of using SCCM server for deploying App-V Applications

October 15, 2009

Convert Virtualbox vdi to VMware vmdk Files

Filed under: Tips — mayankjohri @ 10:57 am
Tags: ,

QEMU-IMG can be used to convert virtualbox vdi file to vmware vmdk file

qemu-img.exe convert -O vmdk virtualbox.vdi vmware.vmdk

October 13, 2009

Demo Calender in wx.python

Filed under: Python — mayankjohri @ 12:47 pm

This is my wx.Calender demo in wx.python

###########################################################################
# -*- coding: ISO-8859-1 -*-
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses>.
__author__ = "Mayank Johri"
__copyright__  = "2009"
__version__ = "0.0.1"
__date__ = "Oct 13 2009"
__license__ = "GNU 3 or latest."
###########################################################################
import re
import datetime
import calendar
import wx
import string
import wx.calendar as cal
import sys
import os
APPDIR = sys.path[0]
TBMENU_RESTORE = wx.NewId()
TBMENU_CLOSE   = wx.NewId()
year = ['January',
     'February',
     'March',
     'April',
     'May',
     'June',
     'July',
     'August',
     'September',
     'October',
     'November',
     'December']
def thismonth():
    """ Presently not using"""
    calendar.setfirstweekday(0)
    today = datetime.datetime.date(datetime.datetime.now())
    current = re.split('-', str(today))
    current_no = int(current[1])
    current_month = year[current_no-1]
    current_day = int(re.sub('\A0', '', current[2]))
    current_yr = int(current[0])
    myCal = '%s %s' %(current_month, current_yr)
    myCal = myCal + '\n' + "M  T  W  Th F  Sa Su" + '\n'
    month = calendar.monthcalendar(current_yr, current_no)
    nweeks = len(month)
    for w in range(0,nweeks):
        week = month[w]
        for x in xrange(0,7):
            day = week[x]
            if x == 5 or x == 6:
                classtype = 'weekend'
            else:
                classtype = 'day'
            if day == 0:
                classtype = 'X'
                myCal = myCal + str(classtype).ljust(3)
            elif day == current_day:
                myCal = myCal + str(day).ljust(3)
            else:
                myCal = myCal + str(day).ljust(3)
        myCal = myCal + '\n'
    return (myCal)
class MyTaskBarIcon(wx.TaskBarIcon):
    def __init__(self, frame):
        wx.TaskBarIcon.__init__(self)
        self.frame = frame
        icon = wx.Icon(os.path.join(APPDIR, 'clock.ico'), wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
        self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarRightClick)
        self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=1)
        self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=2)
    def OnTaskBarRightClick(self, event):
        if not self.frame.IsShown():
            self.frame.Show()
        else: self.frame.Hide()
    def CreatePopupMenu(self):
        menu = wx.Menu()
        menu.Append(1, 'Show/Hide')
        menu.Append(2, 'Close')
        return menu
    def OnTaskBarClose(self, event):
        self.Destroy()
        self.frame.Destroy()

    def OnTaskBarActivate(self, event):
        if not self.frame.IsShown():
            self.frame.Show()
        else: self.frame.Hide()
    def OnTaskBarDeactivate(self, event):
        if self.frame.IsShown():
            self.frame.Hide()
class MayaCalendar(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, title="Maya Calender, Ver: 0.0.1")
        vbox = wx.BoxSizer(wx.VERTICAL)
        calend = cal.CalendarCtrl(self, -1, wx.DateTime_Now(),
            style = cal.CAL_SHOW_HOLIDAYS|cal.CAL_SEQUENTIAL_MONTH_SELECTION)
        vbox.Add(calend, 0, wx.EXPAND | wx.ALL, 20)
        self.Bind(cal.EVT_CALENDAR, self.OnCalSelected, id=calend.GetId())
        self.SetSizerAndFit(vbox)
        self.Show(True)
        self.tskic = MyTaskBarIcon(self)
        self.Centre()
    def OnCalSelected(self, event):
        date = event.GetDate()
        dt = string.split(str(date), ' ')
        s = ' '.join([str(s) for s in dt])
        self.text.SetLabel(s)
class MyApp(wx.App):
    def OnInit(self):
        frame = MayaCalendar(None, -1, 'Maya Calender, Ver: 0.0.1')
        frame.Show(True)
        self.SetTopWindow(frame)
        return True
app = MyApp(0)
app.MainLoop()

October 12, 2009

demo code for wx.TaskBarIcon

Filed under: Python, Tips — mayankjohri @ 3:08 pm
Tags:

Below is the demo code for wx.TaskBarIcon,

import wx
class sysTrayDemo(wx.Frame):
    def __init__(self, parent, id, title):
        pass
        wx.Frame.__init__(self, parent, -1, title, size = (800, 600),
                         style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
        # FIXME: substitute your icon file here.
        icon = wx.Icon('systray.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
        if wx.Platform == '__WXMSW__':
            # setup a taskbar icon, and catch some events from it
            self.tbicon = wx.TaskBarIcon()
            self.tbicon.SetIcon(icon, "SysTray Demo")
            wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
            wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
            wx.EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
            wx.EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
        wx.EVT_ICONIZE(self, self.OnIconify)
        return
    def OnIconify(self, evt):
        self.Hide()
        return
    def OnTaskBarActivate(self, evt):
        if self.IsIconized():
            self.Iconize(False)
        if not self.IsShown():
            self.Show(True)
        self.Raise()
        return
    def OnCloseWindow(self, event):
        if hasattr(self, "tbicon"):
            del self.tbicon
        self.Destroy()
    TBMENU_RESTORE = 1000
    TBMENU_CLOSE   = 1001
    def OnTaskBarMenu(self, evt):
        menu = wx.Menu()
        menu.Append(self.TBMENU_RESTORE, "Restore SysTray Demo")
        menu.Append(self.TBMENU_CLOSE,   "Close")
        self.tbicon.PopupMenu(menu)
        menu.Destroy()
    #---------------------------------------------
    def OnTaskBarClose(self, evt):
        self.Close()
        # because of the way wx.TaskBarIcon.PopupMenu is implemented we have to
        # prod the main idle handler a bit to get the window to actually close
        wx.GetApp().ProcessIdle()
class MyApp(wx.App):
    def OnInit(self):
        self.redirect=True
        frame = sysTrayDemo(None, -1, "SysTray Demo")
        frame.Show(True)
        return True
def main():
    app = MyApp()
    app.MainLoop()
if __name__ == '__main__':
    main()

Sequencing Project 2003 Issue

Filed under: Application Virtualization — mayankjohri @ 11:31 am
Tags: ,

Add the “%appdata%\Microsoft\MS project\” to exclusion list to avoid error while streaming

October 9, 2009

MSI Interview Questions

Filed under: MSI — mayankjohri @ 1:59 pm
Tags: ,
  1. Explain the difference between Property and PROPERTY
  2. Describe the process flow of an installation in terms of the User Interface, Immediate and Deferred sequences
  3. What are the ADDLOCAL and ADDSOURCE properties?
  4. What is the difference between installations using ALLUSERS=””, ALLUSERS=1 and ALLUSERS=2 option?
  5. Advertised vs non-advertised shortcuts, what’s the difference?
  6. Maximum how many files you can add in msi?
  7. ProductCode, PackageCode, UpgradeCode, Explain them
  8. Explain Backend mechanism of Self repair
  9. Suppose you’re in an environment where you can’t use advertisement, explain how you would go about setting userspecific settings
  10. What is the impact of leaving COM information in a generic registry component as apposed to in each relevant component
  11. How many sequences are there in an MSI
  12. Please sketch the entire process of creating a package, from the software request up to package delivery
  13. How many different sequance tables are there in an MSI
  14. Difference between dll/ocx and exe registraction
  15. How we can make two applications with same GUID to install on the same machine?
  16. How we create the small,minor and major upgrade?
  17. what is the disadvantage of using lock permissions table
  18. What are secure custom properties
  19. What is the difference between Repair and Self healing?
  20. What is entry point for MSI?
  21. What should be the condition of a custom action if we want to run it during installation and uninstallation ?
  22. Difference between Run, Run Once, Active Setup
  23. Use of INSTALLLEVEL Property
  24. Self-Heal (advertised shortcut) Vs Install on Demand (product Advertising)
  25. Self-Heal Vs Repair
  26. Per-user installation Vs Per-machine installation
  27. The reason why during a repair, bringing back missing files to System Folders is possible for a standard user who actually does not have a write permission to these folders.
  28. What are your thoughts and experiences for patching .msi files? What approaches have worked the best? What hasn’t worked? Why?
  29. Describe a methodology for populating the user’s profile with Windows Installer functionality. That one was funny because the interviewer was looking for Active Setup which I didn’t consider to be specific to Windows Installer.
  30. How do you configure an installation for an application that requires administrative privileges to work if the end user is not a local machine administrator?
  31. Have you ever had to modify a .msi directly without a graphic interface? Which tables did you modify and why?
  32. Describe the most difficult project you have worked on. What was the problem? How did you solve it? What did you learn?
  33. What tools are in your “packaging toolkit?”
  34. Have you had to edit permissions?
  35. How would you change permissions on files and registry entries?
  36. What are the differences between the lock permissions table and external tools for editing?
  37. How would you populate components from a machine-based installation to a user profile?
  38. What tools do you regularly use asides from your primary tool (WPS or IS or etc…) in the process of creating a package?
  39. An example of a condition you would use, and what it would be useful for.
  40. If you were to receive a vendor MSI, how would you repackage it to comply with company standards?
  41. Do you recommed modifying vendor MSIs? Why/why not?
  42. What are the advantages of using MSIs?
  43. Explain to me what self healing is and how you can leverage it for user specific files/registries
  44. Besides self-healing, what other options do you have for creating user specific files/registries and under what scenarios would you use those?
  45. How would you troubleshoot an application that does not run on a locked down environment but does run as administrator?
  46. When would you use Setup Capture and what kind of clean up would you performed on a captured MSI?
  47. Have you created merge modules? Why?
  48. What is the purpose of Validation and how do you handle ICE errors on vendor MSIs?
  49. Walk me through the entire packaging process from request to deployment you’ve been exposed to in previous roles.

October 6, 2009

Howto: Delete Rows in wx.Grid

Filed under: Python — mayankjohri @ 3:19 am
Tags: , ,
def fm_bDeleteServerDetails(self, event):
lst = self.m_gdServerDetails.GetNumberRows()
selected = []
for r in range(lst):
if self.m_gdServerDetails.IsInSelection(r, 0) == True:
selected.append(r)
selected.reverse()
for r in selected:
self.m_gdServerDetails.DeleteRows(r,1)
	def fm_bDeleteServerDetails(self, event):
		lst = self.m_gdServerDetails.GetNumberRows()
		selected = []
		for r in range(lst):
			if self.m_gdServerDetails.IsInSelection(r, 0) == True:
				selected.append(r)
		selected.reverse()
		for r in selected:
			self.m_gdServerDetails.DeleteRows(r,1)

September 30, 2009

processTame

Filed under: Uncategorized — mayankjohri @ 2:47 pm
Tags:
import os
import sys
import win32process
import win32api
import subprocess
import win32con
def setpriority(pid=None,priority=1):
	priorityclasses = [win32process.IDLE_PRIORITY_CLASS,
	win32process.BELOW_NORMAL_PRIORITY_CLASS,
	win32process.NORMAL_PRIORITY_CLASS,
	win32process.ABOVE_NORMAL_PRIORITY_CLASS,
	win32process.HIGH_PRIORITY_CLASS,
	win32process.REALTIME_PRIORITY_CLASS]
	if pid == None:
	        pid = win32api.GetCurrentProcessId()
        handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
        win32process.SetPriorityClass(handle, priorityclasses[priority])
if (len(sys.argv) == 0):
    print("usage: processtame.exe ")
else:
    if (os.path.exists(sys.argv[1])):
    app = subprocess.Popen(sys.argv[1])
    pid = app.pid
    setpriority(pid, 0)
    app.wait()

September 10, 2009

Searching Machine & User in OU

Filed under: Uncategorized — mayankjohri @ 1:05 pm
Tags: ,

users: dsquery user -name “username”
Computers: dsquery computer -name “computername”

Next Page »

Blog at WordPress.com.