Skip to content

Commit

Permalink
Merge pull request #105 from jacebrowning/relase-2.0
Browse files Browse the repository at this point in the history
Bump version to 2.0
  • Loading branch information
jacebrowning committed Aug 16, 2022
2 parents 4ffc2d0 + 8d712d0 commit b55d531
Show file tree
Hide file tree
Showing 20 changed files with 236 additions and 234 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,4 +1,4 @@
# 2.0 (beta)
# 2.0 (2022-08-16)

- Dropped support for Python 3.6.

Expand Down
6 changes: 3 additions & 3 deletions mine/__init__.py
Expand Up @@ -3,6 +3,6 @@
from pkg_resources import get_distribution


CLI = 'mine'
VERSION = 'mine v{}'.format(get_distribution('mine').version)
DESCRIPTION = 'Share application state across computers using Dropbox.'
CLI = "mine"
VERSION = "mine v{}".format(get_distribution("mine").version)
DESCRIPTION = "Share application state across computers using Dropbox."
70 changes: 35 additions & 35 deletions mine/cli.py
Expand Up @@ -24,17 +24,17 @@ def main(args=None):

# Shared options
debug = argparse.ArgumentParser(add_help=False)
debug.add_argument('-V', '--version', action='version', version=VERSION)
debug.add_argument("-V", "--version", action="version", version=VERSION)
group = debug.add_mutually_exclusive_group()
group.add_argument(
'-v', '--verbose', action='count', default=0, help="enable verbose logging"
"-v", "--verbose", action="count", default=0, help="enable verbose logging"
)
group.add_argument(
'-q',
'--quiet',
action='store_const',
"-q",
"--quiet",
action="store_const",
const=-1,
dest='verbose',
dest="verbose",
help="only display errors and prompts",
)

Expand All @@ -46,35 +46,35 @@ def main(args=None):
parents=[debug],
)
parser.add_argument(
'-d',
'--daemon',
metavar='DELAY',
nargs='?',
"-d",
"--daemon",
metavar="DELAY",
nargs="?",
const=300,
type=int,
help="run continuously with delay [seconds]",
)
parser.add_argument('-f', '--file', help="custom settings file path")
subs = parser.add_subparsers(help="", dest='command', metavar="<command>")
parser.add_argument("-f", "--file", help="custom settings file path")
subs = parser.add_subparsers(help="", dest="command", metavar="<command>")

# Build switch parser
info = "start applications on another computer"
sub = subs.add_parser(
'switch',
description=info.capitalize() + '.',
"switch",
description=info.capitalize() + ".",
help=info,
formatter_class=common.HelpFormatter,
parents=[debug],
)
sub.add_argument(
'name', nargs='?', help="computer to queue for launch (default: current)"
"name", nargs="?", help="computer to queue for launch (default: current)"
)

# Build close parser
info = "close applications on this computer"
sub = subs.add_parser(
'close',
description=info.capitalize() + '.',
"close",
description=info.capitalize() + ".",
help=info,
formatter_class=common.HelpFormatter,
parents=[debug],
Expand All @@ -83,8 +83,8 @@ def main(args=None):
# Build edit parser
info = "launch the settings file for editing"
sub = subs.add_parser(
'edit',
description=info.capitalize() + '.',
"edit",
description=info.capitalize() + ".",
help=info,
formatter_class=common.HelpFormatter,
parents=[debug],
Expand All @@ -93,31 +93,31 @@ def main(args=None):
# Build clean parser
info = "display and delete conflicted files"
sub = subs.add_parser(
'clean',
description=info.capitalize() + '.',
"clean",
description=info.capitalize() + ".",
help=info,
formatter_class=common.HelpFormatter,
parents=[debug],
)
sub.add_argument(
'-f',
'--force',
action='store_true',
"-f",
"--force",
action="store_true",
help="actually delete the conflicted files",
)

# Parse arguments
args = parser.parse_args(args=args)
kwargs = {'delay': args.daemon}
if args.command == 'switch':
kwargs['switch'] = args.name if args.name else True
elif args.command == 'close':
kwargs['switch'] = False
elif args.command == 'edit':
kwargs['edit'] = True
elif args.command == 'clean':
kwargs['delete'] = True
kwargs['force'] = args.force
kwargs = {"delay": args.daemon}
if args.command == "switch":
kwargs["switch"] = args.name if args.name else True
elif args.command == "close":
kwargs["switch"] = False
elif args.command == "edit":
kwargs["edit"] = True
elif args.command == "clean":
kwargs["delete"] = True
kwargs["force"] = args.force

# Configure logging
common.configure_logging(args.verbose)
Expand Down Expand Up @@ -244,5 +244,5 @@ def _restart_daemon(manager):
return True


if __name__ == '__main__': # pragma: no cover (manual test)
if __name__ == "__main__": # pragma: no cover (manual test)
main()
4 changes: 2 additions & 2 deletions mine/common.py
Expand Up @@ -15,7 +15,7 @@ class HelpFormatter(argparse.HelpFormatter):
"""Command-line help text formatter with wider help text."""

def __init__(self, *args, **kwargs):
kwargs['max_help_position'] = 40
kwargs["max_help_position"] = 40
super().__init__(*args, **kwargs)


Expand Down Expand Up @@ -73,7 +73,7 @@ def configure_logging(count=0):
default_format, verbose_format, datefmt=settings.LOGGING_DATEFMT
)
logging.root.handlers[0].setFormatter(formatter)
logging.getLogger('yorm').setLevel(max(level, settings.YORM_LOGGING_LEVEL))
logging.getLogger("yorm").setLevel(max(level, settings.YORM_LOGGING_LEVEL))

# Warn about excessive verbosity
global verbosity
Expand Down
14 changes: 7 additions & 7 deletions mine/manager.py
Expand Up @@ -62,7 +62,7 @@ def wrapped(self, application):
class BaseManager(metaclass=abc.ABCMeta): # pragma: no cover (abstract)
"""Base application manager."""

NAME = FRIENDLY = ''
NAME = FRIENDLY = ""

IGNORED_APPLICATION_NAMES: List[str] = []

Expand Down Expand Up @@ -91,7 +91,7 @@ def _get_process(cls, name):

for process in psutil.process_iter():
try:
command = ' '.join(process.cmdline()).lower()
command = " ".join(process.cmdline()).lower()
parts = []
for arg in process.cmdline():
parts.extend([p.lower() for p in arg.split(os.sep)])
Expand Down Expand Up @@ -123,7 +123,7 @@ def _get_process(cls, name):
class LinuxManager(BaseManager): # pragma: no cover (manual)
"""Application manager for Linux."""

NAME = 'Linux'
NAME = "Linux"
FRIENDLY = NAME

def is_running(self, application):
Expand All @@ -146,8 +146,8 @@ def stop(self, application):
class MacManager(BaseManager): # pragma: no cover (manual)
"""Application manager for OS X."""

NAME = 'Darwin'
FRIENDLY = 'Mac'
NAME = "Darwin"
FRIENDLY = "Mac"

IGNORED_APPLICATION_NAMES = [
"iTunesHelper.app",
Expand Down Expand Up @@ -199,15 +199,15 @@ def stop(self, application):
def _start_app(path):
"""Start an application from it's .app directory."""
assert os.path.exists(path), path
process = psutil.Popen(['open', path])
process = psutil.Popen(["open", path])
time.sleep(1)
return process


class WindowsManager(BaseManager): # pragma: no cover (manual)
"""Application manager for Windows."""

NAME = 'Windows'
NAME = "Windows"
FRIENDLY = NAME

def is_running(self, application):
Expand Down
6 changes: 3 additions & 3 deletions mine/models/computer.py
Expand Up @@ -26,7 +26,7 @@ def get_address(node=None):
"""Get this computer's MAC address."""
if node is None:
node = uuid.getnode()
return ':'.join(("%012X" % node)[i : i + 2] for i in range(0, 12, 2))
return ":".join(("%012X" % node)[i : i + 2] for i in range(0, 12, 2))

@staticmethod
def get_hostname():
Expand Down Expand Up @@ -83,14 +83,14 @@ def get_current(self):

# Else, this is a new computer
this.name = self.generate_name(this)
assert this.name != 'localhost'
assert this.name != "localhost"
log.debug("New computer: %s", this)
self.append(this)
return this

def generate_name(self, computer):
"""Generate a new label for a computer."""
name = computer.hostname.lower().split('.')[0]
name = computer.hostname.lower().split(".")[0]
copy = 1
while name in self.names:
copy += 1
Expand Down
2 changes: 1 addition & 1 deletion mine/models/status.py
Expand Up @@ -123,7 +123,7 @@ def get_latest(self, application):
log.debug(
"%s marked as started on: %s",
application,
', '.join(str(s) for s in states),
", ".join(str(s) for s in states),
)
# TODO: consider returning the computer instance?
return states[0].computer
Expand Down
14 changes: 7 additions & 7 deletions mine/services.py
Expand Up @@ -9,8 +9,8 @@


ROOTS = (r"C:\Users", r"/Users", r"/home")
SERVICES = ('Dropbox', 'Dropbox (Personal)')
CONFIG = 'mine.yml'
SERVICES = ("Dropbox", "Dropbox (Personal)")
CONFIG = "mine.yml"
CONFLICT_BASE = r"{} \(.+'s conflicted copy \d+-\d+-\d+.*\).*"
CONFLICT_ANY = CONFLICT_BASE.format(".+")
CONFLICT_CONFIG = CONFLICT_BASE.format("mine")
Expand All @@ -23,7 +23,7 @@

def find_root(top=None):
"""Get the root of the shared directory."""
top = top or os.path.expanduser('~')
top = top or os.path.expanduser("~")

log.debug("Looking for sharing service in '%s'...", top)
for directory in os.listdir(top):
Expand All @@ -33,7 +33,7 @@ def find_root(top=None):
return path

msg = "no sharing service found"
if os.getenv('CI'):
if os.getenv("CI"):
log.warning(msg)
return top

Expand All @@ -43,7 +43,7 @@ def find_root(top=None):
def find_config_path(top=None, root=None):
"""Get the path to the settings file."""
log.info("Looking for settings file...")
top = top or os.path.expanduser('~')
top = top or os.path.expanduser("~")
root = root or find_root(top=top)

log.debug("Looking for '%s' in '%s'...", CONFIG, root)
Expand All @@ -53,7 +53,7 @@ def find_config_path(top=None, root=None):
del dirnames[:]
continue
path = os.path.join(dirpath, CONFIG)
if os.path.isfile(path) and not os.path.isfile(os.path.join(path, 'setup.py')):
if os.path.isfile(path) and not os.path.isfile(os.path.join(path, "setup.py")):
log.info("Found settings file: %s", path)
return path

Expand All @@ -64,7 +64,7 @@ def delete_conflicts(root=None, config_only=False, force=False):
"""Delete all files with conflicted filenames."""
root = root or find_root()

log.info("%s conflicted files...", 'Deleting' if force else 'Displaying')
log.info("%s conflicted files...", "Deleting" if force else "Displaying")
pattern = CONFLICT_CONFIG if config_only else CONFLICT_ANY
log.debug("Pattern: %r", pattern)
regex = re.compile(pattern)
Expand Down
14 changes: 7 additions & 7 deletions mine/tests/conftest.py
Expand Up @@ -7,28 +7,28 @@
import pytest


ENV = 'TEST_INTEGRATION' # environment variable to enable integration tests
ENV = "TEST_INTEGRATION" # environment variable to enable integration tests
REASON = "'{0}' variable not set".format(ENV)

ROOT = os.path.dirname(__file__)
FILES = os.path.join(ROOT, 'files')
FILES = os.path.join(ROOT, "files")


def pytest_configure(config):
"""Disable verbose output when running tests."""
log.init(
level=log.DEBUG, format="[%(levelname)-8s] (%(name)s @%(lineno)4d) %(message)s"
)
log.silence('yorm', allow_warning=True)
log.silence("yorm", allow_warning=True)

terminal = config.pluginmanager.getplugin('terminal')
terminal = config.pluginmanager.getplugin("terminal")
terminal.TerminalReporter.showfspath = False


def pytest_runtest_setup(item):
if 'linux_only' in item.keywords and platform.system() != 'Linux':
if "linux_only" in item.keywords and platform.system() != "Linux":
pytest.skip("test can only be run on Linux")
if 'mac_only' in item.keywords and platform.system() != 'Darwin':
if "mac_only" in item.keywords and platform.system() != "Darwin":
pytest.skip("test can only be run on OS X")
if 'windows_only' in item.keywords and platform.system() != 'Windows':
if "windows_only" in item.keywords and platform.system() != "Windows":
pytest.skip("test can only be run on Windows")

0 comments on commit b55d531

Please sign in to comment.