# Path: aeriscloud/cli/aeris/sync.py
# def sync(box, direction):
#     if not box.project.rsync_enabled():
#         return None
# 
#     if direction == 'down':
#         click.secho('Syncing files down from the box...',
#                     fg='cyan', bold=True)
#         if box.rsync_down():
#             click.secho('Sync down done!', fg='green', bold=True)
#         else:
#             click.secho('Sync down failed!', fg='red', bold=True)
#             return False
#     elif direction == 'up':
#         click.secho('Syncing files up to the box...',
#                     fg='cyan', bold=True)
#         if box.rsync_up():
#             click.secho('Sync up done!', fg='green', bold=True)
#         else:
#             click.secho('Sync up failed!', fg='red', bold=True)
#             return False
#     else:
#         click.secho('error: invalid direction %s' % direction,
#                     fg='red', bold=True)
#         return False
# 
#     return True
# 
# Path: aeriscloud/cli/helpers.py
# def standard_options(multiple=False, start_prompt=True):
#     """
#     Add the standard --project and --box options to a command
#     :param multiple: Whether to find a single or multiple boxes
#     :param start_prompt: When using single boxes, ask the user to start it if
#                          offline
#     """
#     if multiple:
#         return _multi_box_decorator
#     else:
#         return _single_box_decorator(start_prompt)
# 
# class Command(click.Command):
#     # This is inherited by the Context to switch between pure POSIX and
#     # argparse-like argument parsing. Setting it to false will push any
#     # unknown flag to the argument located where the flag was declared
#     allow_interspersed_args = config.get('config', 'posix', default=False)
# 
#     def __init__(self, *args, **kwargs):
#         cs = dict(help_option_names=['-h', '--help'])
#         super(Command, self).__init__(context_settings=cs,
#                                       *args, **kwargs)


import click
import os
import signal
import sys
import time
from watchdog.observers import Observer
from watchdog.tricks import AutoRestartTrick
from aeriscloud.cli.aeris.sync import sync
from aeriscloud.cli.helpers import standard_options, Command
#!/usr/bin/env python
from __future__ import print_function





class BoxCommandAutoRestart(AutoRestartTrick):
    def __init__(self, box, command, **kwargs):
        AutoRestartTrick.__init__(self, [], **kwargs)
        self.box = box
        self.command = command
        self.state = 'stopped'
        # minimum time between restarts in seconds
        self.last_event = 0
        self.event_buffer = 0.2

    def start(self):
        self.state = 'starting'

# Path: aeriscloud/cli/aeris/sync.py
# def sync(box, direction):
#     if not box.project.rsync_enabled():
#         return None
# 
#     if direction == 'down':
#         click.secho('Syncing files down from the box...',
#                     fg='cyan', bold=True)
#         if box.rsync_down():
#             click.secho('Sync down done!', fg='green', bold=True)
#         else:
#             click.secho('Sync down failed!', fg='red', bold=True)
#             return False
#     elif direction == 'up':
#         click.secho('Syncing files up to the box...',
#                     fg='cyan', bold=True)
#         if box.rsync_up():
#             click.secho('Sync up done!', fg='green', bold=True)
#         else:
#             click.secho('Sync up failed!', fg='red', bold=True)
#             return False
#     else:
#         click.secho('error: invalid direction %s' % direction,
#                     fg='red', bold=True)
#         return False
# 
#     return True
# 
# Path: aeriscloud/cli/helpers.py
# def standard_options(multiple=False, start_prompt=True):
#     """
#     Add the standard --project and --box options to a command
#     :param multiple: Whether to find a single or multiple boxes
#     :param start_prompt: When using single boxes, ask the user to start it if
#                          offline
#     """
#     if multiple:
#         return _multi_box_decorator
#     else:
#         return _single_box_decorator(start_prompt)
# 
# class Command(click.Command):
#     # This is inherited by the Context to switch between pure POSIX and
#     # argparse-like argument parsing. Setting it to false will push any
#     # unknown flag to the argument located where the flag was declared
#     allow_interspersed_args = config.get('config', 'posix', default=False)
# 
#     def __init__(self, *args, **kwargs):
#         cs = dict(help_option_names=['-h', '--help'])
#         super(Command, self).__init__(context_settings=cs,
#                                       *args, **kwargs)


# Path: aeriscloud/cli/aeris/watch.py
import click
import os
import signal
import sys
import time
from watchdog.observers import Observer
from watchdog.tricks import AutoRestartTrick
from aeriscloud.cli.aeris.sync import sync
from aeriscloud.cli.helpers import standard_options, Command

#!/usr/bin/env python
from __future__ import print_function





class BoxCommandAutoRestart(AutoRestartTrick):
    def __init__(self, box, command, **kwargs):
        AutoRestartTrick.__init__(self, [], **kwargs)
        self.box = box
        self.command = command
        self.state = 'stopped'
        # minimum time between restarts in seconds
        self.last_event = 0
        self.event_buffer = 0.2

    def start(self):
        self.state = 'starting'

        sync(self.box, 'up')