コード例 #1
0
ファイル: test_config.py プロジェクト: tking2724/live-magic
 def testNoDirectory(self):
     self.tearDown()
     Config(self.dir)
コード例 #2
0
    def on_wizard_apply(self, asst):
        data, build_dir = self.view.get_wizard_completed_details()

        if build_dir in (self.get_homedir(),
                         os.path.expanduser('~/DebianLive')):
            build_dir = os.path.expanduser('~/DebianLive/build-%s' %
                                           time.strftime('%Y-%m-%d-%H%M-%S'))
        elif len(os.listdir(build_dir)) != 0:
            build_dir = os.path.join(build_dir, 'DebianLive')

        existed_before = os.path.exists(build_dir)

        # Use cdebootstrap in some situations
        if os.path.exists('/usr/bin/cdebootstrap') and \
                                data['distribution'] in ('lenny',):
            data['bootstrap'] = 'cdebootstrap'

        # Disabling caching
        data['cache_stages'] = 'none'
        data['cache_packages'] = False

        self.model = Config(build_dir, **data)

        self.view.do_dim_wizard()

        os.chdir(build_dir)

        def gain_superuser():
            global _
            title = _("Enter your password to continue")
            text = _(
                "Debian Live Magic requires superuser capabilities to build your Debian Live system."
            )

            for num in range(3):
                cmd = [
                    'gksu',
                    '--disable-grab',
                    '--preserve-env',
                    '--message',
                    '<big><b>%s</b></big>\n\n%s' % (title, text),
                    '--',
                    utils.find_resource('live-magic'),
                    '--build-for',
                    '%d:%d' % (os.geteuid(), os.getegid()),
                ]
                p = subprocess.Popen(cmd)

                os.waitpid(p.pid, 0)

                # If build-log.txt exists, we had a successful build
                if os.path.exists(os.path.join(self.model.dir,
                                               'build-log.txt')):
                    gobject.timeout_add(0, lambda: gtk.main_quit())
                    return

                # If the build directory does not exist, we cancelled the build
                if not os.path.exists(self.model.dir):
                    break

            self.view.do_undim_wizard()
            os.chdir('..')

            try:
                if not existed_before:
                    shutil.rmtree(self.model.dir)
            except:
                # Tree may not exist if we cancelled build
                pass

        threading.Thread(target=gain_superuser).start()
コード例 #3
0
ファイル: test_config.py プロジェクト: tking2724/live-magic
 def setUp(self):
     import tempfile
     self.dir = tempfile.mkdtemp()
     self.lh = Config(self.dir)
コード例 #4
0
 def testSpaceInValue(self):
     lh = Config(self.dir, packages_lists="hello there")
     self.assertEqual(lh.chroot['LH_PACKAGES_LISTS'], ['hello', 'there'])
コード例 #5
0
 def testAllowPassingOptionsSecondTime(self):
     lh = Config(self.dir, packages_lists="one two")
     lh = Config(self.dir, packages_lists="three four")
     self.assertEqual(lh.chroot['LH_PACKAGES_LISTS'], ['three', 'four'])
コード例 #6
0
 def testHyphenatedOption(self):
     lh = Config(self.dir, packages_lists='my-package-list')
     self.assertEqual(lh.chroot['LH_PACKAGES_LISTS'], ['my-package-list'])
コード例 #7
0
 def testArchChangesKernelFlavour(self):
     lh_i386 = Config(self.dir, architecture='i386')
     self.setUp()
     lh_amd64 = Config(self.dir, architecture='amd64')
     self.assertNotEqual(lh_i386.chroot['LH_LINUX_FLAVOURS'],
         lh_amd64.chroot['LH_LINUX_FLAVOURS'])
コード例 #8
0
 def testNoOptions(self):
     lh = Config(self.dir)
コード例 #9
0
 def testArchAmd64(self):
     lh = Config(self.dir, architecture='amd64')
     self.assertEqual(lh.bootstrap['LH_ARCHITECTURE'], 'amd64')
コード例 #10
0
 def testArch386(self):
     lh = Config(self.dir, architecture='i386')
     self.assertEqual(lh.bootstrap['LH_ARCHITECTURE'], 'i386')