Just released the py2html tool. It make easy to highlight your python code to embedded in your web site.
Changing the default google calendar event length Tuesday, Jan 20 2009
Google App Engine and How To and MS Windows 2:35 pm
The default event time for all google calendar is one hour (1 hour), and there is no way to have it configurable. Most of therapist needs 30 minutes event, and for those who uses the google agenda, it is quite bit effort to get it right. There are already several posts asking how to change this time, but till now no response from google team. So I have creted a very small program to make it easy to have 30 minutes event.
- Download the executable
- Execute it. You will notice a new Z icon at your system tray
- You will notice a new tray icon (Z)
- Now open the firefox and navigate to your google calendar page
- Press ALT-Z and type the name of the patient and the the starting time.
e.g: Albert 13:30
It is a good idea to make a startup shortcut to save even more time ; -)
The script was compiled by AutoHotKey, and its source code can be download here
Configuring Eclipse to Use With Google App Engine Friday, Nov 14 2008
Google App Engine 10:19 pm
Walk-Through
Installing the PyDev plug-in:
- Click on menu items:
Help > Software Updates > Available Software (tab) > Add Site - Type:
http://pydev.sourceforge.net/updates/ - Click on [OK button]
- Check the PyDev For Eclipse option:
- + http://pydev.sourceforge.net/updates/
- – + Pydev
- – - + [X] PyDev For Eclipse
- Click on [Install button] and Wait
- Click on [Next button]
- Click on “I accept the terms of the license agreement” option
- Click on [Finish button] and wait
- Click on [YES button] to restart Eclipse
Configuring the python interpreter:
- Click on menu items:
Window > Preferences - Open the nodes:
- + Pydev
- – + Interpreter – Python - Click on [New button]
- Browse the python.exe application
Windows default: C:\Python25\python.exe
Linux default: /opt/bin/python2.5
- Click on [OK button] to add the suggested folders to the pythonpath
- Click on [Ok Button] to confirm
Creating a GoogleApp project:
- Right-Click on Project Explorer
- Choose:
New > Other - Select “PyDev Project” option:
- + Pydev
– - + Pydev Project - Click on [Next button]
- Type the project name:
helloworld - Select the python 2.5 as target project type
- Click on [Finish button]
- adding the GoogleApp Engine libraries
- In the PyDev Package Explorer panel
- Right Click on your new project
- Select the Properties option
- Select the PyDev – PYTHONPATH item
- Click on [Add source folder button] of the External Source Folders panel
- Add each of the following folders:
Windows default:- C:\Program Files\Google\google_appengine\lib\django
- C:\Program Files\Google\google_appengine\lib\webob
- C:\Program Files\Google\google_appengine\lib\yaml
- C:\Program Files\Google\google_appengine\lib\
- C:\Program Files\Google\google_appengine\
- Click on [OK button] to confirm
Editing the application sources
- In the PyDev Package Explorer panel
- Right Click on your project
- Select:
new > file option - In the File name edit box type:
app.yaml - Click on [Finish button]
- In the source editor type the following text:
application: helloworld version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
- In the PyDev Package Explorer panel
- Right Click on your project
- Select
new > file option - In the File name edit box type:
helloworld.py - Click on [Finish button]
- In the source editor type the following text:
print 'Content-Type: text/plain' print '' print 'Hello, world!'
Running the Application
- Click on
Run > Run Configurations - in the Main Tab:
- Select Python Run option and name your new configuration:
type hello - Click the Project [Browse button]
- Select the helloworld project and click [OK button]
- On the Main Module text box type:
C:\Program Files\Google\google_appengine\dev_appserver.py
- Select Python Run option and name your new configuration:
- In the Arguments Tab:
- Type the following code into the Program Arguments:
“${project_loc}”note: any supported dev_appserver.py argument line can be entered. You may for instance type:
“${project_loc}”
–port=9999 - Click on [Apply button]
- Click on [Run button]
- Type the following code into the Program Arguments:
References
Portable Google Chrome – II Friday, Sep 5 2008
Google App Engine 7:38 am
Plasmid sent me a nice tip that I put here in his own words:
“…if you move ‘chrome.exe’ and ‘Dictionaries’ into the 0.2.149.27 directory, you should
be able to copy the whole lot onto a USB stick and it works without needing the registry keys!”
So no run.bat file or registry entries are needed.
He has created a really portable chrome browser
Thank you Plasmid – Great Job!!!
Marco
Portable Google Chrome Version (9.3Mb) Wednesday, Sep 3 2008
Google App Engine and How To and MS Windows Browser, Chrome, Google Chrome, Portable, Windows XP 4:06 pm
Google Chrome is really nice, but it does a quite dirty installation… It write several registry entries, does not give you the option to select where you want to install, forces the bookmark importation from the current default browser, etc.
Yes, it is possible to run this brilliant browser in any folder you desire. No configuration is needed, but also a single language is enabled (American Engligh).
How to install this portable version:
- Download and uncompress the GoogleChromePortable.zip in any folder you want.
- Execute the RUN.BAT file (on the windows explorer, open the GoogleChromePortable folder and double-click on it)
That’s all.
Enjoy it
Netbios Alias Tuesday, Jun 24 2008
Google App Engine 10:53 am
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
Hands-On #7 Working with gcalendar events on GAD Thursday, May 22 2008
Google App Engine 11:12 pm
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
Google App Engine 10:25 pm
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
Google App Engine 11:01 am
A really simple way to send e-mail:
import pygtk
pygtk.require(‘2.0′)
import gtk
import smtplibclass 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.FALSEdef 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
Google App Engine 10:07 pm
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()