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

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:


date = time.strftime("%x")
date = time.strftime("%x")
f = open("day.txt","r+")
f = open("dates.txt","w")
m = open("dates.txt")
lines = m.readlines()


places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite")
places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite")
Line 19: Line 21:
database.execute('''SELECT url FROM moz_places''')
database.execute('''SELECT url FROM moz_places''')


 
if lines:
for line in f:
    for line in lines:
    if not date: #check this
        if data not in line:
        for data in database:
            for data in database:
            database.execute('''DELETE FROM moz_places WHERE url=?''',(data))
                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"]
url_list = ["https://www.youtube.com","https://www.facebook.com","http://www.reddit.com","http://vodly.to","http://www.lastfm.com"]


def getCount():
def getCount():
Line 39: Line 40:


count = getCount()
count = getCount()
f.write(date)
f.close()


print "Content-Type: text/html"
print "Content-Type: text/html"
Line 64: Line 62:
         height: ;
         height: ;
         position: fixed;
         position: fixed;
         top: 0;
         top: 1.3%;
         left: 0;
         left: 0;
         }
         }
Line 70: Line 68:
     </head>
     </head>
     """
     """
 
if count < 13:
if count < 14:
     print """
     print """
     <body>
     <body>
Line 78: Line 75:
     print """
     print """
     <body>
     <body>
     <img src ='/procrastimeterip.png'/>  
     <img src ='/count_dracula.gif'/>  
     """
     """
    f.write(date+"\n")
    f.close()
print """
print """
     </body>
     </body>

Latest revision as of 20:41, 30 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("dates.txt","w")
m = open("dates.txt")
lines = m.readlines()

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

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

if lines:
     for line in lines:
         if data not in line:
             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()

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: 1.3%;
        left: 0;
        }
    </style>
    </head>
    """
if count < 13:
    print """
    <body>
    <img src='/procrastimeter%s.png'/> """ % count
else:
    print """
    <body>
    <img src ='/count_dracula.gif'/> 
    """
    f.write(date+"\n")
    f.close()
print """
    </body>
    </html> """


Procrastinatometer2.png