User:Yoana Buzova/ prototyping: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 31: Line 31:


Altijd Vrij (Free for all) – This allows totally unrestricted free browsing for the user.
Altijd Vrij (Free for all) – This allows totally unrestricted free browsing for the user.
== script ==
<source lang="python">
import subprocess, re, os, datetime, time
while True:
    now = datetime.datetime.now()
    print "."
    if now.hour >= 9 and now.hour < 14:
        # BASH: ps aux
        # to get list of all processes
        proc = subprocess.Popen(['ps aux'], stdout=subprocess.PIPE, shell=True)
        (out, err) = proc.communicate()
        for line in out.splitlines():
            line = line.lower()
            if 'firefox' in line or 'safari' in line or 'chrom' in line:
                parts = re.split(r"\s*", line)
                pid = parts[1]
                print pid
                os.system("kill "+pid)
    else:
        print "Not time to quit"
    time.sleep(5)
</source>

Revision as of 17:12, 29 May 2013

MY browser / mmths + yoana


Closed-sign.jpg




Closed.png]]



make an add-on to create working times for your browser the user could choose from a few different options (inspiration from the NS railways korting system)


Cyberslacker - Browsing is available during the week from 09:00-17:00.

Night surfer - Your browser is open on weekdays from 18:30-04:00.

Dal Voordeel (Off-peak surfing) – Your browser is not available between the peak hours of 06:30-09:00 and 16:00-18:30.

Weekend Vrij (Weekend free browsing) – Your browser is available only at the weekend, from Friday 18:30 to Monday 04:00.

Altijd Vrij (Free for all) – This allows totally unrestricted free browsing for the user.

script

import subprocess, re, os, datetime, time


while True:
    now = datetime.datetime.now()
    print "."

    if now.hour >= 9 and now.hour < 14:
        # BASH: ps aux
        # to get list of all processes 
        proc = subprocess.Popen(['ps aux'], stdout=subprocess.PIPE, shell=True)
        (out, err) = proc.communicate()

        for line in out.splitlines():
            line = line.lower()
            if 'firefox' in line or 'safari' in line or 'chrom' in line:
                parts = re.split(r"\s*", line)
                pid = parts[1]
                print pid
                os.system("kill "+pid)
    else:
        print "Not time to quit"


    time.sleep(5)