Skip to main content

Posts

Showing posts with the label python

Bash and Python scripts to unzip and modify an OpenOffice odt document

.odt files are actually containers (you can see one using unzip -l document.odt ). Within the container, content is in the content.xml file. Script info source Heres what Ive figured out about opening, modifying, and saving the content of an .odt file: To open the container for editing: # bash $unzip path/container.odt content.xml $unzip path/container.odt content.xml -d working/dir/path/ # -d places content.xml in a different directory. # Creates a content.xml file where you want it. # python >>>import zipfile >>>odt_file = zipfile.ZipFile(path/to/file.odt,a) >>> # Options are read only, write only, and append to existing >>>raw_xml = odt_file.read(content.xml) >>> # Reads content.xml in as a string, doesnt place a file. Modify the content.xml file by hand, or using a script, or using Python. >>> # Tip for using python: ElementTree is good at XML, and it can parse a file, but it cannot parse a string! >>> # So heres h...

Beginner Python with Raspberry Pi Tips

Below are some tips for beginners who want to develop python program on Raspberry Pi (assuming you are using Windows as the development environment. 1. Interact with Raspberry Pi After connect rasberry pi to your computer, you need to configure the ip address of your network adapter, to ssh login to raspberry pi (e.g. configure an address such as 10.0.2.15), use Putty which can be downloaded from http://www.putty.org/ . After launching Putty, enter the "10.0.2.15" as  the address and select ssh and 22 as the port, and connect 2. Install TightVNC server for remote GUI access to Raspberry Pi Accessing raspberry pi via putty or ssh wont allow you to launch the raspbian x11 GUI by running command such as "startx". In that case, you can use TightVNC server allows you to remote login to the Raspbian x11 GUI on the raspberry pi so that you can interact with the raspberry pi in its GUI. >> sudo apt-get update >> sudo apt-get install -y tightvncserver To start an...