User:Lidia.Pereira/PNMII/WB/PCM: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
[[File:Procrastinatometer.png|755px]]
[[File:Procrastinatometer.png|755px]]


Disclaimer: For now this is a personal script, seeing that it works with the sqlite database which stores my browsing history.  
Disclaimer: For now this is a local script, seeing that it works with the sqlite database which stores my browsing history.  
In the future I'll try developing a browser plug-in (using Grease Monkey, perhaps) that does the same without depending on some local file.
In the future I'll try developing a browser plug-in (using Grease Monkey, perhaps) that does the same without depending on some local file.



Revision as of 23:26, 3 March 2014

Procrastinatometer.png

Disclaimer: For now this is a local script, seeing that it works with the sqlite database which stores my browsing history. In the future I'll try developing a browser plug-in (using Grease Monkey, perhaps) that does the same without depending on some local file.

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sqlite3
import time

date = time.strftime("%x")
f = open("day.txt","r+")

places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite")
database = places.cursor()

database.execute('''SELECT url FROM moz_places''')


for line in f:
    if not date: #check this
        for data in database:
            database.execute('''DELETE FROM moz_places WHERE url=?''',(data))


url_list = ["https://www.youtube.com","https://www.facebook.com","http://www.reddit.com","http://vodly.to","http://www.lastfm.com"]


def getCount():
    i = 0
    for data in database:
        data = str(data)
        for url in url_list:
            if url in data:
                i = i + 1
    return i

count = getCount()

f.write(date)
f.close()

print "Content-Type: text/html"
print 
print """
    <!DOCTYPE html>
    <html>
    <head>
    <title>Procrastinatometer</title>
    <style>
        html{
        background: url('/procrastinatometer.png') no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
        }
        img{
        min-height: 100%;
        min-width: 1024px;
        width: 100%;
        height: ;
        position: fixed;
        top: 0;
        left: 0;
        }
    </style>
    </head>
    """

if count < 14:
    print """
    <body>
    <img src='/procrastimeter%s.png'/> """ % count
else:
    print """
    <body>
    <img src ='/procrastimeterip.png'/> 
    """
print """
    </body>
    </html> """


Procrastinatometer2.png