Netbios Alias Tuesday, Jun 24 2008 

On the target machine:

1. Start the registry editor (regedt32.exe)
2. Move to HKEY_Local_Machine\System\CurrentC­ ontrolSet\Services\LanmanServer\Pa­ rameters
3. From the Edit menu select “Add Value”
4. Set the type to REG_SZ is you want one extra name or REG_MULTI_SZ if you want more than one and enter a name of OptionalNames. Click OK
5. You will then be prompted for a value. Enter the other name (or names if type REG_MULTI_SZ, one on each line) you want it to be known as and click OK.
6. Close the registry editor
7. Reboot the machine

Set up a Lexmark E120n laser printer on Ubuntu 8.04 LTS Friday, May 30 2008 

  • Download the ppd file and saving it in a temporary directory – such as /tmp
  • Select “Printer -> Add a printer”
  • In the type of printer field “check printer and list” Printer CUPS (IPP) “
  • In the field “URI” type the URI of your printer, for instance  “ipp: / / 192.168.0.49:80″
  • Click on Install driver button
  • Select the file ‘‘LexmarkE120n.ppd” from the directory you saved it.
  • Fill in the fields name, “E120n
  • Click on Apply button

Hands-On #7 Working with gcalendar events on GAD Thursday, May 22 2008 

here are some few conversions needed to have the calendar events “when” objects converted into GAD DateTimeProperty model values.

The first thing we must keep in mind is: the calendar “when” object returns a list to be interacted, and get the calender event start and end time strings.  So, you  should have something like the piece of code below:

query = gdata.calendar.service.CalendarEventQuery(‘default’, ‘private’, ‘full’, text_query)

feed = calendar_service.CalendarQuery(query)
for i, an_event in enumerate(feed.entry):
print ‘\t%s. %s’ % (i, an_event.title.text,)
print ‘\t\t%s. %s’ % (i, an_event.content.text,)
for a_when in an_event.when:
print ‘\t\tStart time: %s’ % (a_when.start_time,)
print ‘\t\tEnd time:   %s’ % (a_when.end_time,)

The start_time and end_time are simple strings in UTC format. Such values looks like something as “2008-05-23T08:30:10.000-03:00″. So you have the date: (2008-05-23), the time (08:30:10.000) and the time zone (-03:00 is one of the Brazilian zone). Once you don´t have a way to enter the seconds, milliseconds and the time zone in a single calendar event, the best thing to do is cut them out. So we will use the slice notation to do that.  Just keep the first 16 characters from the datetime string  [:16], and them proceed with the convertion using the strptime datetime function. This function parses a string input to a datetime object based on a given string format.

Take a look at this simple example:

class DateTime(db.Model):
when = db.DateTimeProperty(auto_now_add=False, required=False)

aDateTime = DateTime()
aDateTime.when = datetime.datetime.strptime(w.start_time[:16],”%Y-%m-%dT%H:%M”)

Hands-On #6 Setting up GData for Google Appengine Tuesday, May 6 2008 

There are some important updates need for having the SDK 1.0.2 and GData API 1.0.13 properly working.

  • Configure the GData libraries:
    In this task list I´m considering that your google appengine installation path is:
    C:\Program Files\Google\google_appengine\. Please adjust this piece of information if it does not match with your location.
  • Download the latest gdata-python-client file and uncompress its content in a temporary folder
  • Copy the entire src folder to C:\Program Files\Google\google_appengine\lib folder
  • Rename the src folder to gdata-python-client
  • Edit the urlfetch.py file located at:
    C:\Arquivos de programas\Google\google_appengine\lib\gdata-python-client\gdata\urlfetch.py
  • replace line 153 content from
    return self.headers[name]
    to
    return self.headers[name.lower()]
  • Replace your C:\Arquivos de programas\Google\google_appengine\google\appengine\api\urlfetch_stub.py by this file hacked urlfetch_stub.py file according to the AppDevEngine Issue 341
  • Edit the root dev_appserver.py located at
    C:\Program Files\Google\google_appengine\dev_appserver.py
  • Add a new line after line 43 with the following content:
    os.path.join(DIR_PATH, ‘lib’, ‘gdata-python-client’),The complete block must look like this:EXTRA_PATHS = [
    DIR_PATH,
    os.path.join(DIR_PATH, 'lib', 'django'),
    os.path.join(DIR_PATH, 'lib', 'webob'),
    os.path.join(DIR_PATH, 'lib', 'gdata-python-client'),
    os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
    ]
  • save and close this file
  • Edit the root dev_appserver.py located at
    C:\Arquivos de programas\Google\google_appengine\google\appengine\tools\dev_appserver.py
  • “Change lines 1140-1141 of dev_appserver.py from:if (file_type != self._imp.C_BUILTIN and
    not FakeFile.IsFileAccessible(pathname)):to:

    if (file_type != self._imp.C_BUILTIN and
    file_type != self._imp.C_EXTENSION and
    not FakeFile.IsFileAccessible(pathname))”

    The dev_appserver.py file can be located at <Installation dir>\Google
    \google_appengine\google\appengine\tools

  • Save and close this file

Hands-On #5 Quick Email… with python and GTK Tuesday, Apr 29 2008 

A really simple way to send e-mail:

import pygtk
pygtk.require(‘2.0′)
import gtk
import smtplib

class DlgSendMail:
def onSend(self, widget, data=None):
fr = “your name”
to = self.txtTo.get_text()
ms = self.txtMsg.get_text()
smtp = smtplib.SMTP(’smtp.server.com.br’)
smtp.login(‘account@smtpservercom.br’, ‘password’)
smtp.sendmail(fr, to, ms)
smtp.quit()
gtk.mainquit()

def delete_event(self, widget, event, data=None):
print “delete event occurred”
return gtk.FALSE

def destroy(self, widget, data=None):
gtk.mainquit()

def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect(“delete_event”, self.delete_event)
self.window.connect(“destroy”, self.destroy)
self.window.set_border_width(10)
self.window.set_usize(300, 100)
self.window.set_title(“GTK SendMail”)

#create a 2×2 table
self.table = gtk.Table(3, 2, gtk.TRUE)
self.window.add(self.table)

#to label field
self.lblTo = gtk.Label(“To:”)
self.lblTo.set_alignment(1,1)
self.window.add(self.lblTo)
self.table.attach(self.lblTo, 0, 1, 0, 1)
self.lblTo.show()

#to Input field
self.txtTo = gtk.Entry()
self.window.add(self.txtTo)
self.table.attach(self.txtTo, 1, 2, 0, 1)
self.txtTo.show()

#message label field
self.lblMsg = gtk.Label(“Message:”)
self.lblMsg.set_alignment(1,1)
self.window.add(self.lblMsg)
self.table.attach(self.lblMsg, 0, 1, 1, 2)
self.lblMsg.show()

#message Input field
self.txtMsg = gtk.Entry()
self.window.add(self.txtMsg)
self.table.attach(self.txtMsg, 1, 2, 1, 2)
self.txtMsg.show()

#button send
self.button = gtk.Button(“Sent Now”)
self.button.connect(“clicked”, self.onSend, None)
self.button.connect_object(“clicked”, self.window.destroy, self.window)
self.window.add(self.button)
self.table.attach(self.button, 0, 2, 2, 3)
self.button.show()

#show everything
self.table.show()
self.window.show()

def main(self):
gtk.main()

if __name__ == “__main__”:
dlg = DlgSendMail()
dlg.main()

Hands-On #4 Retrieving a list of the user calendars Monday, Apr 28 2008 

Print a list of the defined user calendars:

try:
from xml.etree import ElementTree # for Python 2.5 users
except ImportError:
from elementtree import ElementTree
import gdata.calendar.service
import gdata.service
import atom.service
import gdata.calendar
import atom
import getopt
import sys
import string
import time

def PrintUserCalendars(calendar_service):
  feed = calendar_service.GetAllCalendarsFeed()
  print feed.title.text
  for i, a_calendar in enumerate(feed.entry):
    print '\t%s. %s' % (i, a_calendar.title.text,)

def main():
  calendar_service = gdata.calendar.service.CalendarService()
  calendar_service.email = ';-@gmail.com'
  calendar_service.password = ':o('
  calendar_service.source = 'Google-Calendar_Python_Sample-1.0'
  calendar_service.ProgrammaticLogin()
  PrintUserCalendars(calendar_service)

if __name__ == '__main__':
 main()

Hands-On #03 Generating a Google Doc file list Friday, Apr 25 2008 

  • Download the file tc02.zip
  • Uncompress it
  • Edit the listdocs.py file and replace the e-mail/password
  • Run the dev_appserver.py

The dev_appserver should be already fixed – see the previous post.

Hands-On #02 Fixing dev_appserver for xml parsing use Friday, Apr 25 2008 

It seems that the dev_appserver.py module is not prepared for C_EXTENSION as well. As consequence, the xml parser pyexpat can not be used. The google data python api, will use those feature when retrieving list of feeds as shown below:

client = gdata.docs.service.DocsService()
client.ClientLogin(‘your_email@gmail.com’, ‘your_password’)
documents_feed = client.GetDocumentListFeed()

The bold line will work fine on python enviroment, but it will crash when running under the dev_appserver control.

There is already an opened issue (http://code.google.com/p/googleappengine/issues/detail?id=83)

The suggested workaround solved my problem:

“Change lines 1140-1141 of dev_appserver.py from:

if (file_type != self._imp.C_BUILTIN and
not FakeFile.IsFileAccessible(pathname)):

to:

if (file_type != self._imp.C_BUILTIN and
file_type != self._imp.C_EXTENSION and
not FakeFile.IsFileAccessible(pathname))”

The dev_appserver.py file can be located at <Installation dir>\Google
\google_appengine\google\appengine\tools

Hands on – For a sustainable world… Thursday, Apr 17 2008 

Just disclosing some great ideas -
PT – Apenas divulgando algumas grandes idéia…

Pity, all texts are in portuguese!
Any volunteer?

Hands On #1 – Google App Engine Wednesday, Apr 16 2008 

Target Development Enviroment

  • MS Windows XP/2000
  • Requisites:
    • here the suggested folder was used:
      C:\Python25
  • Google App Engine SDK Installed
    • here the suggested folder was used:
      %ProgramFiles%googlegoogle_appengine

      e.g: C:Program Filesgooglegoogle_appengine

    • Install the sample application:
      • Application 1: tc01
      • Description: Test Case 01 – tc01 – Add two numbers and Guest book application
      • Installation:
    • Download the application tc01.zip file
    • Uncompress its content (TC01) in temporary folder (for instance: C:\Temp)
      e.g: C:\temp\tc01
  • open a command prompt
    • go to previous application folder (C:temp in my case)
    • type:
      C:> cd temp
    • run the application web server:
    • type:
      dev_appserver.py tc01
  • Execution:
    • browse the url:
      http://localhost:8080/

    « Previous PageNext Page »