Merge b1d1e3467c
into fbd2227a3c
This commit is contained in:
commit
7f26ff1887
|
@ -1,5 +1,6 @@
|
||||||
from mixpanel import Mixpanel
|
from mixpanel import Mixpanel
|
||||||
|
|
||||||
|
|
||||||
class Analytics:
|
class Analytics:
|
||||||
# Setup analytics.
|
# Setup analytics.
|
||||||
# dnt - do not track. Disables tracking if True
|
# dnt - do not track. Disables tracking if True
|
||||||
|
@ -7,17 +8,19 @@ class Analytics:
|
||||||
def __init__(self, dnt, token):
|
def __init__(self, dnt, token):
|
||||||
self.dnt = dnt
|
self.dnt = dnt
|
||||||
self.tracker = Mixpanel(token)
|
self.tracker = Mixpanel(token)
|
||||||
if(self.dnt == True):
|
if(self.dnt is True):
|
||||||
print "[+] Analytics disabled"
|
print("[+] Analytics disabled")
|
||||||
# Track an event
|
# Track an event
|
||||||
# event - string containing the event name
|
# event - string containing the event name
|
||||||
# data - data related to the event, defaults to {}
|
# data - data related to the event, defaults to {}
|
||||||
def track(self, event, data = {}):
|
|
||||||
if(self.dnt == False):
|
def track(self, event, data={}):
|
||||||
|
if(self.dnt is False):
|
||||||
# All events are tracked anonymously
|
# All events are tracked anonymously
|
||||||
self.tracker.track("anonymous", event, data)
|
self.tracker.track("anonymous", event, data)
|
||||||
# Track a visit to a URL
|
# Track a visit to a URL
|
||||||
# The url maybe an HN submission or
|
# The url maybe an HN submission or
|
||||||
# some meta-url pertaining to hackertray
|
# some meta-url pertaining to hackertray
|
||||||
|
|
||||||
def visit(self, url):
|
def visit(self, url):
|
||||||
self.track('visit', {"link":url})
|
self.track('visit', {"link": url})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#=========================
|
# =========================
|
||||||
#
|
#
|
||||||
# AppIndicator for GTK
|
# AppIndicator for GTK
|
||||||
# drop-in replacement
|
# drop-in replacement
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
# Copyright 2010
|
# Copyright 2010
|
||||||
# Nathan Osman
|
# Nathan Osman
|
||||||
#
|
#
|
||||||
#=========================
|
# =========================
|
||||||
|
|
||||||
# We require PyGTK
|
# We require PyGTK
|
||||||
import gtk
|
import gtk
|
||||||
|
@ -29,7 +29,9 @@ STATUS_ATTENTION = 1
|
||||||
|
|
||||||
def get_icon_filename(icon_name):
|
def get_icon_filename(icon_name):
|
||||||
# Determine where the icon is
|
# Determine where the icon is
|
||||||
return os.path.abspath(resource_filename('hackertray.data', 'hacker-tray.png'))
|
return os.path.abspath(
|
||||||
|
resource_filename('hackertray.data', 'hacker-tray.png')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# The main class
|
# The main class
|
||||||
|
|
|
@ -4,8 +4,10 @@ import shutil
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Chrome:
|
class Chrome:
|
||||||
HISTORY_TMP_LOCATION = '/tmp/hackertray.chrome'
|
HISTORY_TMP_LOCATION = '/tmp/hackertray.chrome'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def search(urls, config_folder_path):
|
def search(urls, config_folder_path):
|
||||||
Chrome.setup(config_folder_path)
|
Chrome.setup(config_folder_path)
|
||||||
|
@ -13,17 +15,19 @@ class Chrome:
|
||||||
db = conn.cursor()
|
db = conn.cursor()
|
||||||
result = []
|
result = []
|
||||||
for url in urls:
|
for url in urls:
|
||||||
db_result = db.execute('SELECT url from urls WHERE url=:url',{"url":url})
|
# db_result = db.execute(
|
||||||
if(db.fetchone() == None):
|
# 'SELECT url from urls WHERE url=:url',{"url":url})
|
||||||
|
if db.fetchone() is None:
|
||||||
result.append(False)
|
result.append(False)
|
||||||
else:
|
else:
|
||||||
result.append(True)
|
result.append(True)
|
||||||
os.remove(Chrome.HISTORY_TMP_LOCATION)
|
os.remove(Chrome.HISTORY_TMP_LOCATION)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup(config_folder_path):
|
def setup(config_folder_path):
|
||||||
file_name = os.path.abspath(config_folder_path+'/History')
|
file_name = os.path.abspath(config_folder_path + '/History')
|
||||||
if not os.path.isfile(file_name):
|
if not os.path.isfile(file_name):
|
||||||
print("ERROR: ", "Could not find Chrome history file", file=sys.stderr)
|
print("ERROR: ", "Could not find Chrome history file",file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
shutil.copyfile(file_name, Chrome.HISTORY_TMP_LOCATION)
|
shutil.copyfile(file_name, Chrome.HISTORY_TMP_LOCATION)
|
||||||
|
|
|
@ -4,9 +4,11 @@ import shutil
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Firefox:
|
class Firefox:
|
||||||
HISTORY_TMP_LOCATION = '/tmp/hackertray.firefox'
|
HISTORY_TMP_LOCATION = '/tmp/hackertray.firefox'
|
||||||
HISTORY_FILE_NAME = '/places.sqlite'
|
HISTORY_FILE_NAME = '/places.sqlite'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def search(urls, config_folder_path):
|
def search(urls, config_folder_path):
|
||||||
Firefox.setup(config_folder_path)
|
Firefox.setup(config_folder_path)
|
||||||
|
@ -14,16 +16,19 @@ class Firefox:
|
||||||
db = conn.cursor()
|
db = conn.cursor()
|
||||||
result = []
|
result = []
|
||||||
for url in urls:
|
for url in urls:
|
||||||
db_result = db.execute('SELECT url from moz_places WHERE url=:url',{"url":url})
|
# db_result = db.execute(
|
||||||
if(db.fetchone() == None):
|
# 'SELECT url from moz_places WHERE url=:url',{"url":url})
|
||||||
|
if db.fetchone() is None:
|
||||||
result.append(False)
|
result.append(False)
|
||||||
else:
|
else:
|
||||||
result.append(True)
|
result.append(True)
|
||||||
os.remove(Firefox.HISTORY_TMP_LOCATION)
|
os.remove(Firefox.HISTORY_TMP_LOCATION)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup(config_folder_path):
|
def setup(config_folder_path):
|
||||||
file_name = os.path.abspath(config_folder_path+Firefox.HISTORY_FILE_NAME)
|
file_name = os.path.abspath(
|
||||||
|
config_folder_path + Firefox.HISTORY_FILE_NAME)
|
||||||
if not os.path.isfile(file_name):
|
if not os.path.isfile(file_name):
|
||||||
print("ERROR: ", "Could not find Firefox history file", file=sys.stderr)
|
print("ERROR: ", "Could not find Firefox history file", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import requests
|
import requests
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
class Version:
|
class Version:
|
||||||
PYPI_URL = "https://pypi.python.org/pypi/hackertray/json"
|
PYPI_URL = "https://pypi.python.org/pypi/hackertray/json"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def latest():
|
def latest():
|
||||||
res = requests.get(Version.PYPI_URL).json()
|
res = requests.get(Version.PYPI_URL).json()
|
||||||
|
@ -14,14 +16,16 @@ class Version:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new_available():
|
def new_available():
|
||||||
latest = Version.latest()
|
latest = Version.latest()
|
||||||
current = Version.current()
|
current = Version.current()
|
||||||
try:
|
try:
|
||||||
if pkg_resources.parse_version(latest) > pkg_resources.parse_version(current):
|
if pkg_resources.parse_version(latest) > pkg_resources.parse_version(current):
|
||||||
print "[+] New version " + latest + " is available"
|
print("[+] New version " + latest + " is available")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print "[+] There was an error in trying to fetch updates"
|
print("[+] There was an error in trying to fetch updates")
|
||||||
return False
|
return False
|
Loading…
Reference in New Issue