Example #1
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')
        # osnap expects this dir so we have to make it, even though its empty
        os.makedirs(self.test_name, exist_ok=True)

        subprocess.check_call('./make_osnapy.sh', shell=True)  # has to be via shell since we have to get elevated sudo
        subprocess.check_call('./make_installer.sh', shell=True)

        try:
            os.remove(status_file_path)
        except FileNotFoundError:
            pass
        subprocess.check_call('open ./dist/%s.app' % self.test_name, env={}, shell=True)
        while not os.path.exists(status_file_path):
            time.sleep(3)
            print('waiting for %s (%s)' % (status_file_path, str(time.time())))
        shutil.move(status_file_path, spafit.get_status_file_name(self.test_name))

        print('%s done' % self.test_name)

        return True
Example #2
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)
        try:
            os.remove(status_file_path)
        except FileNotFoundError:
            pass

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')

        with open('cx_freeze_mac_1_error.log', 'w') as f1:
            cmd = '%s setup.py build' % os.path.join('venv', 'bin', 'python')
            print(cmd)
            subprocess.call(cmd, stderr=f1, stdout=f1, shell=True)
            time.sleep(2)

        # todo: if this ever works, actually call the app

        print('%s done' % self.test_name)

        return True
Example #3
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)

        try:
            os.remove(status_file_path)
        except FileNotFoundError:
            pass

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')

        # todo: make a function to make the log file name (don't do it manually every time - could end up with inconsistencies)
        with open('briefcase_1_error.log', 'w') as f:
            cmd = '%s setup.py win' % os.path.join('venv', 'scripts',
                                                   'python.exe')
            print(cmd)
            subprocess.check_call(cmd, env={}, stdout=f, stderr=f, shell=True)

        print('%s done' % self.test_name)

        return True
Example #4
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)
        try:
            os.remove(status_file_path)
        except FileNotFoundError:
            pass

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')

        with open('pyinstaller_mac_1_error.log', 'w') as f1:
            # --windowed provides the main.app (OSX 'application')
            pyinstaller_cmd = '%s -y --noupx --windowed -d main.py' % os.path.join(
                'venv', 'bin', 'pyinstaller')
            print(pyinstaller_cmd)
            subprocess.call(pyinstaller_cmd, stderr=f1, shell=True)
            time.sleep(2)

        with open('pyinstaller_mac_2_error.log', 'w') as f1:
            open_cmd = 'open ./dist/%s.app' % self.test_name
            print(open_cmd)
            subprocess.call(open_cmd, env={}, shell=True)

        print('%s done' % self.test_name)

        return True
Example #5
0
    def run(self):

        # todo: make this common across pynsist, py2exe, and osnap
        elevate_tool_path = os.path.join(os.sep, 'Elevation', 'elevate.cmd')

        for d in ['build']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        # todo: make a routine that gets us the base dir for installed files
        #uninstall_cmd = '%s' % os.path.join(os.sep, 'Program Files', 'pynsist', 'uninstall.exe')
        #if os.path.exists(uninstall_cmd):
        #    print(uninstall_cmd)
        #    subprocess.check_call(uninstall_cmd, shell=True)

        spafit.copy_files('..', '.')

        nsist_cmd = '%s -m nsist installer.cfg' % os.path.join('venv', 'Scripts', 'python.exe')
        print(nsist_cmd)
        subprocess.check_call(nsist_cmd)
        time.sleep(2)

        if not os.path.exists(elevate_tool_path):
            print('error: %s does not exist' % elevate_tool_path)
            print('get it from http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/Elevation2008_06.exe')
            print('see https://technet.microsoft.com/en-us/library/cc510320.aspx for more information')
            return False
        install_cmd = '%s %s' % (elevate_tool_path, os.path.join('build', 'nsis', 'pynsist_1.0.exe'))
        print(install_cmd)
        subprocess.check_call(install_cmd)

        pyw_exe = os.path.join(os.sep, 'Windows', 'pyw.exe')
        launch_pyw = os.path.join(os.sep, 'Program Files', 'pynsist', 'pynsist.launch.pyw')
        while not os.path.exists(launch_pyw):
            print('waiting for %s' % launch_pyw)
            time.sleep(5)
        time.sleep(10)  # ensure all files written out
        launch_cmd = '%s "%s" %s' % (pyw_exe, launch_pyw, os.path.abspath(spafit.get_status_file_name(self.test_name)))
        print(launch_cmd)
        subprocess.check_call(launch_cmd, shell=True)

        return True
Example #6
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)
        try:
            os.remove(status_file_path)
        except FileNotFoundError:
            pass

        for d in ['build', 'dist', '.eggs']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')

        # py2app won't work from my venv so I have to install (pollute) my base python3
        # e.g. https://bitbucket.org/ronaldoussoren/py2app/issues/61/py2app-run-in-virtualenv-does-not-copy
        #  and https://github.com/micahflee/onionshare/issues/241
        subprocess.check_call('%s install -U -r requirements.txt' %
                              spafit.get_pip_path(),
                              env={},
                              shell=True)
        subprocess.check_call('%s setup.py py2app' % spafit.get_python_path(),
                              env={},
                              shell=True)

        try:
            subprocess.check_call('open ./dist/main.app', env={}, shell=True)
        except subprocess.CalledProcessError:
            pass

        try:
            shutil.move(status_file_path,
                        spafit.get_status_file_name(self.test_name))
        except FileNotFoundError:
            pass

        spafit.trim_log(self.test_name)

        print('%s done' % self.test_name)

        return True
Example #7
0
    def run(self):

        status_file_path = spafit_mac.get_mac_status_file_path(self.test_name)

        if False:
            try:
                os.remove(status_file_path)
            except FileNotFoundError:
                pass

            for d in ['build', 'dist', 'macOS']:
                try:
                    shutil.rmtree(d)
                except FileNotFoundError:
                    pass

            spafit.copy_files('..', '.')

            subprocess.check_call('venv/bin/pip3 install -U -r requirements.txt', env={}, shell=True)
            subprocess.check_call('venv/bin/python3 setup.py macos', env={}, shell=True)

        try:
            subprocess.check_call('open ./macOS/main.app', env={}, shell=True)
        except subprocess.CalledProcessError:
            pass

        try:
            shutil.move(status_file_path, spafit.get_status_file_name(self.test_name))
        except FileNotFoundError:
            pass

        spafit.trim_log(self.test_name)

        # if it doesn't work, do this so we can see the error
        # note that if it doesn't work, the call will fail, so we can't do a check_call()
        subprocess.call('./macOS/main.app/Contents/MacOS/main > %s_2_error.log 2>&1' % self.test_name, env={},
                        shell=True)

        print('%s done' % self.test_name)

        return True
Example #8
0
    def run(self):

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        spafit.copy_files('..', '.')

        with open('pyinstaller_1_error.log', 'w') as f1:
            # eventually add --windowed but leave it out now so we can capture the error output from the executable
            pyinstaller_cmd = '%s -y --noupx -d main.py' % os.path.join(
                'venv', 'Scripts', 'pyinstaller.exe')
            print(pyinstaller_cmd)
            subprocess.call(pyinstaller_cmd, stderr=f1)
            time.sleep(2)

        with open('pyinstaller_2_error.log', 'w') as f2:
            main_dir = os.path.abspath(os.path.join('dist', 'main'))
            main_exe_path = os.path.join(main_dir, 'main.exe')
            subprocess.call(main_exe_path, cwd=main_dir, stderr=f2)

        return True
Example #9
0
    def run(self):

        # todo: make this common across pynsist and osnap
        elevate_tool_path = os.path.join(os.sep, 'Elevation', 'elevate.cmd')

        for d in ['build', 'dist']:
            try:
                shutil.rmtree(d)
            except FileNotFoundError:
                pass

        uninstall_cmd = '%s' % os.path.join(os.sep, 'Program Files (x86)',
                                            'author', 'osnap_win',
                                            'uninstall.exe')
        if os.path.exists(uninstall_cmd):
            print(uninstall_cmd)
            subprocess.check_call(uninstall_cmd, shell=True)
        # todo: figure out how to wait until the uninstall is completed

        spafit.copy_files('..', '.')
        # osnap expects this dir so we have to make it, even though its empty
        os.makedirs(self.test_name, exist_ok=True)

        osnap_test_util.make_osnapy(True)
        subprocess.check_call('make_installer.bat', shell=True)

        # todo: make this a function somehow to share across pynsist and osnap
        if not os.path.exists(elevate_tool_path):
            print('error: %s does not exist' % elevate_tool_path)
            print(
                'get it from http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/Elevation2008_06.exe'
            )
            print(
                'see https://technet.microsoft.com/en-us/library/cc510320.aspx for more information'
            )
            return False
        install_cmd = '%s %s' % (elevate_tool_path,
                                 os.path.join('installers',
                                              'osnap_win_installer.exe'))
        print(install_cmd)
        subprocess.check_call(install_cmd)

        # todo: make a routine that gets us the base dir for installed files
        osnap_win_exe = os.path.join(os.sep, 'Program Files (x86)', 'author',
                                     'osnap_win', 'osnap_win.exe')
        while not os.path.exists(osnap_win_exe):
            print('waiting for %s' % osnap_win_exe)
            time.sleep(5)
        time.sleep(10)  # ensure all files written out
        launch_cmd = '"%s"' % osnap_win_exe
        print(launch_cmd)
        subprocess.check_call(launch_cmd, shell=True)

        # currently osnap doesn't take parameters, so we initially get the default file name
        status_file_path = os.path.abspath(spafit.get_status_file_name())
        while not os.path.exists(status_file_path):
            time.sleep(3)
            print('waiting for %s' % status_file_path)
        shutil.move(status_file_path,
                    spafit.get_status_file_name(self.test_name))

        return True