Example #1
0
def local_watchman_dir():
    if os.environ.get('LOCAL_WATCHMAN') or \
            '/usr/local/siphon-cli' not in os.path.dirname(__file__):
        watchman_dir = None
    elif get_platform_name() == PLATFORM_DARWIN:
        watchman_dir = os.path.join(CLI_DIR, 'watchman', 'osx-64')
    else:
        watchman_dir = None
    return watchman_dir
Example #2
0
def run(args):
    if args is None:
        args = []
    if '--help' in args:
        print_usage()
        return

    # Check that we're on a mac
    if get_platform_name() != PLATFORM_DARWIN:
        print('You must run the Siphon client on OS X in order to use this ' \
              'feature. Please use our Sandbox app, which is available on ' \
              'the App Store.')
        return

    if not osx_version_supported():
        print('OS X %s or higher is required to run this command. Please ' \
              'visit the App Store and upgrade you operating system. '
              % MIN_OSX_VERSION)
        return

    # Make sure the required dependencies are installed
    ensure_xcode_dependencies()

    sim_data = IOSSimulatorData()
    platform_version = sim_data.latest_platform_version()

    if len(args) == 1 and args[0] == '--list-sims':
        print_sims()
        return

    # Use the global installation of watchman if specified
    global_watchman = False
    if '--global-watchman' in args:
        global_watchman = True
        args.remove('--global-watchman')

    if len(args) == 2 and args[0] == '--simulator':
        sim_name = args[1]
        sim = sim_data.get_sim(sim_name, platform_version)
        if not sim:
            puts(colored.red('Invalid simulator name provided.'))
            print_sims()
            return
        develop(sim, default_sim=False, global_watchman=global_watchman)
        return
    elif len(args) > 0:
        print_usage()
        return

    sim = sim_data.default_sim()
    develop(sim, global_watchman=global_watchman)
Example #3
0
def run(args):
    if args is None:
        args = []
    if '--help' in args:
        print_usage()
        return

    # Check that we're on a mac
    if get_platform_name() != PLATFORM_DARWIN:
        print('You must run the Siphon client on OS X in order to use this ' \
              'feature. Please use our Sandbox app, which is available on ' \
              'the App Store.')
        return

    if not osx_version_supported():
        print('OS X %s or higher is required to run this command. Please ' \
              'visit the App Store and upgrade you operating system. '
              % MIN_OSX_VERSION)
        return

    # Make sure the required dependencies are installed
    ensure_xcode_dependencies()

    sim_data = IOSSimulatorData()
    platform_version = sim_data.latest_platform_version()

    if len(args) == 1 and args[0] == '--list-sims':
        print_sims()
        return

    # Use the global installation of watchman if specified
    global_watchman = False
    if '--global-watchman' in args:
        global_watchman = True
        args.remove('--global-watchman')

    if len(args) == 2 and args[0] == '--simulator':
        sim_name = args[1]
        sim = sim_data.get_sim(sim_name, platform_version)
        if not sim:
            puts(colored.red('Invalid simulator name provided.'))
            print_sims()
            return
        develop(sim, default_sim=False, global_watchman=global_watchman)
        return
    elif len(args) > 0:
        print_usage()
        return

    sim = sim_data.default_sim()
    develop(sim, global_watchman=global_watchman)
Example #4
0
def prompt_for_upgrade():
    pricing_url = 'https://getsiphon.com/pricing/'
    print('Sorry, publishing is a paid feature and it appears that you do ' \
        'not have a paid subscription yet. Please visit our pricing page ' \
        'to find out how to upgrade:\n\n==> %s' % pricing_url)
    if get_platform_name() == PLATFORM_DARWIN:
        msg = '\nWould you like to open the pricing page now and ' \
            'upgrade? [Y/n]: '
        try:
            if get_input(colored.green(msg)) in ('Y', 'y', ''):
                bash('open %s' % pricing_url)
        except KeyboardInterrupt:
            print()
    else:
        print('\nAfter upgrading, try running this command again to ' \
            'publish your app.')
Example #5
0
def prompt_for_upgrade():
    pricing_url = 'https://getsiphon.com/pricing/'
    print('Sorry, publishing is a paid feature and it appears that you do ' \
        'not have a paid subscription yet. Please visit our pricing page ' \
        'to find out how to upgrade:\n\n==> %s' % pricing_url)
    if get_platform_name() == PLATFORM_DARWIN:
        msg = '\nWould you like to open the pricing page now and ' \
            'upgrade? [Y/n]: '
        try:
            if get_input(colored.green(msg)) in ('Y', 'y', ''):
                bash('open %s' % pricing_url)
        except KeyboardInterrupt:
            print()
    else:
        print('\nAfter upgrading, try running this command again to ' \
            'publish your app.')
Example #6
0
def run(args):
    # Check that we're on a mac
    if get_platform_name() != PLATFORM_DARWIN:
        print('You must run the Siphon client on OS X in order to use this ' \
              'feature. Please use our Sandbox app, which is available on ' \
              'the App Store.')
        return

    if not osx_version_supported():
        print('OS X %s or higher is required to run this command. Please ' \
              'visit the App Store and upgrade you operating system. '
              % MIN_OSX_VERSION)
        return

    # Make sure the required dependencies are installed
    ensure_xcode_dependencies()
    dev_mode = False

    if len(args) == 1 and args[0] == '--help':
        print_usage()
        return
    elif len(args) == 2 and args[0] == '--set-apple-username':
        cache = Cache()
        cache.set_apple_username(args[1])
        cache.clear_ios()
        return
    elif len(args) == 1 and args[0] == '--clear-builds':
        clear_builds()
        return
    elif len(args) == 1 and args[0] == '--dev':
        dev_mode = True
    elif args:
        print_usage()
        return

    if not dev_mode:
        puts(colored.yellow('## Run your app with dev mode enabled for ' \
            'more detailed logs and warning messages: siphon play --dev'))

    device = IOSDevice.get_device()
    if not device:
        puts(colored.red('No device detected. Please connect your ' \
        'device and try again.'))
        return
    cert_installed = ensure_wwdr_cert()
    if cert_installed:
        play(device, dev_mode)
Example #7
0
def run(args):
    # Check that we're on a mac
    if get_platform_name() != PLATFORM_DARWIN:
        print('You must run the Siphon client on OS X in order to use this ' \
              'feature. Please use our Sandbox app, which is available on ' \
              'the App Store.')
        return

    if not osx_version_supported():
        print('OS X %s or higher is required to run this command. Please ' \
              'visit the App Store and upgrade you operating system. '
              % MIN_OSX_VERSION)
        return

    # Make sure the required dependencies are installed
    ensure_xcode_dependencies()
    dev_mode = False

    if len(args) == 1 and args[0] == '--help':
        print_usage()
        return
    elif len(args) == 2 and args[0] == '--set-apple-username':
        cache = Cache()
        cache.set_apple_username(args[1])
        cache.clear_ios()
        return
    elif len(args) == 1 and args[0] == '--clear-builds':
        clear_builds()
        return
    elif len(args) == 1 and args[0] == '--dev':
        dev_mode = True
    elif args:
        print_usage()
        return

    if not dev_mode:
        puts(colored.yellow('## Run your app with dev mode enabled for ' \
            'more detailed logs and warning messages: siphon play --dev'))

    device = IOSDevice.get_device()
    if not device:
        puts(colored.red('No device detected. Please connect your ' \
        'device and try again.'))
        return
    cert_installed = ensure_wwdr_cert()
    if cert_installed:
        play(device, dev_mode)
Example #8
0
def mixpanel_event(name, username=None, properties=None):
    """
    Takes an event name and a dict of args and registers it with Mixpanel.
    If the username is None, it will assumed that it can be found in a
    .siphon file in the directory.
    """
    # Use AsyncBufferedConsumer to avoid blocking the main thread
    mp = Mixpanel(MIXPANEL_TOKEN, consumer=AsyncBufferedConsumer())
    if not username:
        auth = Auth()
        username = auth.username

    props = {'user_platform': get_platform_name()}
    if properties:
        props.update(properties)

    mp.track(username, name, props)
Example #9
0
def mixpanel_event(name, username=None, properties=None):
    """
    Takes an event name and a dict of args and registers it with Mixpanel.
    If the username is None, it will assumed that it can be found in a
    .siphon file in the directory.
    """
    # Use AsyncBufferedConsumer to avoid blocking the main thread
    mp = Mixpanel(MIXPANEL_TOKEN, consumer=AsyncBufferedConsumer())
    if not username:
        auth = Auth()
        username = auth.username

    props = {'user_platform': get_platform_name()}
    if properties:
        props.update(properties)

    mp.track(username, name, props)
Example #10
0
def ensure_node(version):
    if not node_cmd(version):
        # Neither a valid global or siphon installation was found, so we
        # must download the correct binary.
        version_exists = NODE_BINARIES.get(version)
        if not version_exists:
            puts(colored.red('Base version not supported. Please set ' \
                 'the "base_version" value in your app\'s Siphonfile to one ' \
                 'of the following: '))

            for k in reversed(sorted(list(NODE_BINARIES.keys()))):
                print(k)
            sys.exit(1)

        if get_platform_name() != PLATFORM_DARWIN:
            raise SiphonClientException('Node not supported on platform.')

        url = NODE_BINARIES[version]['darwin-64']['url']
        node_size = format_size(get_download_size(url))
        proceed = yn('We need to download Node.js & npm (we won\'t override ' \
                    'any current installations you may have). ' \
                    'These are required to run the packager and download ' \
                    'any dependencies we need. Download? (%s) ' \
                    '[Y/n] ' % node_size)

        if not proceed:
            sys.exit(1)
        version_dest = os.path.join(NODE_DESTINATION, version)
        ensure_dir_exists(version_dest)
        dest = os.path.join(version_dest, os.path.basename(url))
        download_file(url, dest, 'Downloading Node.js & npm...')
        print('Installing node...')
        tf = tarfile.open(dest, 'r:gz')
        content_dir = os.path.join(version_dest,
                  NODE_BINARIES[version]['darwin-64']['content'])
        tf.extractall(version_dest)
        move_contents_to_parent(content_dir)
        print('Installation successful.')