28 January, 2016

27 January, 2016

Pandoc error

Looking for at solution for this pandoc error message:

pandoc-citeproc:
Error at "source" (line 1, column 94):
unexpected end of input
expecting new-line
http://student.bus.olemiss.edu/files/conlon/others/others/semantic%20web%20papers/roadmap.pdf


Python and MySQL on Linux Mint

Got an error because the MySQLdb package wasn't found. Solution:

# apt-cache search MySQLdb

python-mysqldb - Pythongrænseflade for MySQL
python-mysqldb-dbg - Pythonbrugerflade til MySQL (fejlsøgningsudvidelse)
bibus - Bibliografisk database
mysql-utilities - collection of scripts for managing MySQL servers
petj-HP-EliteBook-850-G1 ~ # apt-get install python-mysqldb

Then

# sudo apt-get install python-mysqldb

Then everything worked like a charm. 

24 January, 2016

Tomboy Notes

My old laptop literaly crashed. Litterally. During the reconstruction efforts I found out, that one of my primary concerns was to get the Tomboy Notes.

The files are stored in:

~/.local/share/tomboy

Then:

  • #killall tomboy
  • copy the files from the backup
  • paste the files to ~/.local/share/tomboy
  • start tomboy
That's it.

13 January, 2016

How to make an icon for a Python App

The files and the icon.


So now I have some Python GUIs for my Philips HUE, but I'd like to have a nice Desktop Icon, like any other Linux App. How can I do this?

In Ubuntu - and probably most Linux systems the paths to executable programs are stored in hidden .desktop files.

First create a file and save it as .myApp.desktop

The content of the file could look like this:


[Desktop Entry]
Name=Test
Exec=/home/per/Dokumenter/bin/bin/hue/python/tkinterNoter/tkEntry.py
Icon=/home/per/Dokumenter/bin/bin/hue/python/tkinterNoter/multimusen.png
Terminal=false
Type=Application
GenericName="Python tkEntry Exp"

There are more possible setting, see here.

The next step is to make your file executable, write these commands in the terminal window:

# chmod a+x .myApp.desktop
# chmod a+x tkEntry.py
# cp .*desktop ~/.local/share/applications/

In order to give all system user access to your program, you can:

# cp .*desktop /usr/share/applications

Now you'll see an icon with the chosen picture in the folder. You can drag this icon to e.g. the menu. And now you can run your GUI as you would run any program.

The line Terminal can be true or false. If it's true the program will launch in a terminal window.

11 January, 2016

Json Parsing in Python (Philips Hue Sample)

Import libraries:

import requests
import json
from urllib import urlopen

Here's a class that will print out the names of the scenes:

    ''' AUTORUN METHOD '''
    def __init__(self,master):

        self.apiUrl = "http://192.168.0.11/api"
        self.user = "xxxxxxxxxxxxxxxxxxxxxxxxx"

        self.a = urlopen(self.apiUrl 
            + "/" 
            + self.user 
            + "/" 
            + "scenes").read()
        self.a = json.loads(self.a)
 
        for thing in self.a:
            self.theName = self.a.get( thing ).get('name')
            print self.theName

The function will print out a list of scene names.