Commit 45630b14 authored by Nimesh's avatar Nimesh

Updated

parent 07489627
Application,Time,Percentage
chrome,0:05:14,86
code,0:00:42,11
python3,0:00:06,2
gnome-terminal,0:00:04,1
------------------------------------------------------------
chrome
0:05:14 (86%)
------------------------------------------------------------
0:02:53 (55%) Read Library of Heaven’s Path - Chapter 707: Start of the Hunt online free - Novel Full - Google Chrome
0:02:16 (43%) Read Library of Heaven’s Path - Chapter 706: Elder Mo online free - Novel Full - Google Chrome
0:00:03 (1%) Protracktor/source/window_activity.py · master · Nimesh / Protracktor · GitLab - Google Chrome
0:00:02 (1%) (4) WhatsApp - Google Chrome
------------------------------------------------------------
code
0:00:42 (11%)
------------------------------------------------------------
0:00:42 (100%) window_activity.py - source - Visual Studio Code
------------------------------------------------------------
python3
0:00:06 (2%)
------------------------------------------------------------
0:00:06 (100%) Close Window
------------------------------------------------------------
gnome-terminal
0:00:04 (1%)
------------------------------------------------------------
0:00:04 (100%) sony@sony-SVF15212SNW: ~/CS699/Protracktor/source
============================================================
started: 2020-11-18 11:38:40 updated: 2020-11-18 11:45:20
============================================================
\ No newline at end of file
{
"python3": {
"Upload": 0.0031004,
"Download": 0.0495367,
"total": 0.052637100000000006
}
}
\ No newline at end of file
......@@ -23,12 +23,9 @@ pltdir = "../results/ActivityTracker/usage_graph"
def currtime(tformat=None):
'''
This method checks for the file and returns the time in respective format.
:param tformat: string argument
:returns: date and time
'''
return time.strftime("%Y_%m_%d_%H_%M_%S") if tformat == "file"\
else time.strftime("%Y-%m-%d %H:%M:%S")
try:
......@@ -51,12 +48,9 @@ log2 = csvdir+"/"+read_config()+currtime("file")+".csv"; startt = currtime()
def get(command):
'''
This method gets the output of the command and converts it into utf-8 format
:param command: list argument
:returns: output of command in utf-8 format
'''
try:
return subprocess.check_output(command).decode("utf-8").strip()
except subprocess.CalledProcessError:
......@@ -65,12 +59,9 @@ def get(command):
def time_format(s):
'''
This method coverts cumulative time in seconds into HH:MM:SS
:param s: total seconds time
:returns: time in HH:MM:SS format
'''
m, s = divmod(s, 60); h, m = divmod(m, 60)
return "%d:%02d:%02d" % (h, m, s)
......@@ -78,7 +69,6 @@ def summarize(t,winlist,applist):
'''
This is heart of the program it lists the applications and corresponding duration of usage for each application
'''
with open(log1, "wt" ) as report:
totaltime = sum([it[2] for it in winlist])
report.write("")
......@@ -121,11 +111,10 @@ def plot():
This method is used for plotting the bar graph from the final csv file
generated by summarize() method
'''
try:
data = pd.read_csv(log2)
except FileNotFoundError:
return
return
df = pd.DataFrame(data)
name = df['Application']
perc = df['Percentage']
......@@ -150,12 +139,10 @@ class myThread4 (threading.Thread):
'''
It is a threading class which is controlled by our main application file
'''
def __init__(self):
'''
Initiates the window activity tracking process
'''
threading.Thread.__init__(self)
self.flag=0
self.t = 0
......@@ -166,13 +153,11 @@ class myThread4 (threading.Thread):
'''
This method triggers to close the thread
'''
self.flag=1
def run(self):
'''
This method initiates and continuosly runs the activity tracking with the help of other methods
'''
while True:
time.sleep(period)
if self.flag==1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment