Support default firefox profile

This commit is contained in:
Nemo 2020-06-15 00:16:34 +05:30
parent 01ad187150
commit ff57182c3c
6 changed files with 30 additions and 15 deletions

5
.gitignore vendored
View File

@ -17,4 +17,7 @@ var/
# Installer logs # Installer logs
pip-log.txt pip-log.txt
pip-delete-this-directory.txt pip-delete-this-directory.txt
pyvenv.cfg
bin/

View File

@ -1,14 +1,20 @@
language: python language: python
python: python:
- "2.7" # https://endoflife.date/python
# goes away in sep 2020
- "3.5"
# goes away in dec 2021
- "3.6" - "3.6"
# goes away in jun 2023
- "3.7"
# goes away in oct 2024
- "3.8"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: install:
- pip install requests - pip install requests
- pip install nose - pip install nose
- pip install mixpanel-py
# command to run tests, e.g. python setup.py test # command to run tests, e.g. python setup.py test
script: nosetests --nocapture script: nosetests --nocapture
notifications: notifications:
email: email:
on_success: never on_success: never

View File

@ -3,7 +3,12 @@ This file will only list released and supported versions, usually skipping over
Unreleased Unreleased
========== ==========
* Python 3 upgrade 4.0.0
=====
* Upgrades to Python 3.0. Python 2 is no longer supported
* Switches from PyGtk to PyGObject.
* AppIndicator is no longer supported, because it is Python 2 only
3.0.0 3.0.0
===== =====

View File

@ -87,10 +87,11 @@ class HackerNewsApp:
btnQuit.show() btnQuit.show()
btnQuit.connect("activate", self.quit) btnQuit.connect("activate", self.quit)
self.menu.append(btnQuit) self.menu.append(btnQuit)
self.menu.show() self.menu.show()
self.ind.set_menu(self.menu) self.ind.set_menu(self.menu)
if args.firefox == "auto":
args.firefox = Firefox.default_firefox_profile_path()
self.refresh(chrome_data_directory=args.chrome, firefox_data_directory=args.firefox) self.refresh(chrome_data_directory=args.chrome, firefox_data_directory=args.firefox)
def toggleComments(self, widget): def toggleComments(self, widget):
@ -205,7 +206,7 @@ def main():
parser.add_argument('-v', '--version', action='version', version=Version.current()) parser.add_argument('-v', '--version', action='version', version=Version.current())
parser.add_argument('-c', '--comments', dest='comments', action='store_true', help="Load the HN comments link for the article as well") parser.add_argument('-c', '--comments', dest='comments', action='store_true', help="Load the HN comments link for the article as well")
parser.add_argument('--chrome', dest='chrome', help="Specify a Google Chrome Profile directory to use for matching chrome history") parser.add_argument('--chrome', dest='chrome', help="Specify a Google Chrome Profile directory to use for matching chrome history")
parser.add_argument('--firefox', default=self.default_firefox_profile(), dest='firefox', help="Specify a Firefox Profile directory to use for matching firefox history") parser.add_argument('--firefox', dest='firefox', help="Specify a Firefox Profile directory to use for matching firefox history. Pass auto to automatically pick the default profile")
parser.set_defaults(comments=False) parser.set_defaults(comments=False)
parser.set_defaults(dnt=False) parser.set_defaults(dnt=False)
args = parser.parse_args() args = parser.parse_args()

View File

@ -18,8 +18,8 @@ class Firefox:
parser = configparser.ConfigParser() parser = configparser.ConfigParser()
parser.read(profile_file_path) parser.read(profile_file_path)
for section in parser.sections(): for section in parser.sections():
if parser[section]["Default"] == "1": if parser.has_option(section,"Default") and parser[section]["Default"] == "1":
if parser[section]["IsRelative"] == "1": if parser.has_option(section,"IsRelative") and parser[section]["IsRelative"] == "1":
profile_path = str(Path.home().joinpath(".mozilla/firefox/").joinpath(parser[section]["Path"])) profile_path = str(Path.home().joinpath(".mozilla/firefox/").joinpath(parser[section]["Path"]))
else: else:
profile_path = parser[section]["Path"] profile_path = parser[section]["Path"]
@ -45,8 +45,8 @@ class Firefox:
@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, using %s" % file_name)
sys.exit(1) sys.exit(1)
shutil.copyfile(file_name, Firefox.HISTORY_TMP_LOCATION) shutil.copyfile(file_name, Firefox.HISTORY_TMP_LOCATION)

View File

@ -10,8 +10,8 @@ setup(name='hackertray',
description='Hacker News app that sits in your System Tray', description='Hacker News app that sits in your System Tray',
long_description='HackerTray is a simple Hacker News Linux application that lets you view top HN stories in your System Tray. It relies on appindicator, so it is not guaranteed to work on all systems. It also provides a Gtk StatusIcon fallback in case AppIndicator is not available.', long_description='HackerTray is a simple Hacker News Linux application that lets you view top HN stories in your System Tray. It relies on appindicator, so it is not guaranteed to work on all systems. It also provides a Gtk StatusIcon fallback in case AppIndicator is not available.',
keywords='hacker news hn tray system tray icon hackertray', keywords='hacker news hn tray system tray icon hackertray',
url='http://captnemo.in/hackertray', url='https://captnemo.in/hackertray',
author='Abhay Rana', author='Abhay Rana (Nemo)',
author_email='me@captnemo.in', author_email='me@captnemo.in',
license='MIT', license='MIT',
packages=find_packages(), packages=find_packages(),