コード例 #1
0
ファイル: volume.py プロジェクト: wbrxcorp/walbrix
def enter():
    if selected == 0:
        wbui.play_sound("click")
        create_vg()
        return
    else:
        # vgに対するオペレーションメニューを表示
        wbui.play_sound("click")
        vg = vglist[selected - 1]["name"]
        lvs = subprocess.Popen("lvs --noheadings --separator='|' %s" % (vg),
                               shell=True,
                               stdout=subprocess.PIPE,
                               close_fds=True)
        line = lvs.stdout.readline()
        lv_list = []
        while line:
            lv = line.split("|")[0].strip()
            lv_list.append(lv)
            line = lvs.stdout.readline()
        lvs.wait()
        operations = [{
            "label": gui.res.string_volume_remove
        }, {
            "label": gui.res.string_logic_volume,
            "id": "lvs"
        }]
        if len(lv_list) == 0:
            operations[0]["id"] = "remove"

        operation = gui.selectbox.execute(vg, operations)
        if operation == "remove":
            if dialogbox.messagebox.execute(
                    gui.res.string_volume_del_area %
                (vg), dialogbox.DialogBox.OKCANCEL()) != "ok":
                return None
            if system.exec_shell("vgremove -f %s" % (vg)) == 0:
                dialogbox.messagebox.execute(gui.res.string_volume_deleted %
                                             (vg))
            else:
                dialogbox.messagebox.execute(gui.res.string_not_remove % (vg),
                                             None, gui.res.caution_sign)
            refresh()
        elif operation == "lvs":
            max_show = 20
            msg = gui.res.string_logical_volume_included % (vg)
            if len(lv_list) == 0:
                msg += gui.res.string_do_not
            else:
                for i in range(0, min(len(lv_list), max_show)):
                    if i > 0:
                        msg += ","
                    msg += lv_list[i]
                if i < len(lv_list) - 1:
                    msg += (gui.res.string_other % (len(lv_list) - max_show))
            dialogbox.messagebox.execute(msg)
コード例 #2
0
ファイル: volume.py プロジェクト: wbrxcorp/walbrix
def enter():
    if selected == 0:
        wbui.play_sound("click")
        create_vg()
        return
    else:
        # vgに対するオペレーションメニューを表示
        wbui.play_sound("click")
        vg = vglist[selected - 1]["name"]
        lvs = subprocess.Popen("lvs --noheadings --separator='|' %s" % (vg), shell=True, stdout=subprocess.PIPE, close_fds=True)
        line = lvs.stdout.readline()
        lv_list = []
        while line:
            lv = line.split("|")[0].strip()
            lv_list.append(lv)
            line = lvs.stdout.readline()
        lvs.wait()
        operations = [{"label":gui.res.string_volume_remove},{"label":gui.res.string_logic_volume,"id":"lvs"}]
        if len(lv_list) == 0:
            operations[0]["id"] = "remove"

        operation = gui.selectbox.execute(vg, operations)
        if operation == "remove":
            if dialogbox.messagebox.execute(gui.res.string_volume_del_area % (vg), dialogbox.DialogBox.OKCANCEL()) != "ok":
                return None
            if system.exec_shell("vgremove -f %s" % (vg)) == 0:
                dialogbox.messagebox.execute(gui.res.string_volume_deleted % (vg))
            else:
                dialogbox.messagebox.execute(gui.res.string_not_remove % (vg), None, gui.res.caution_sign)
            refresh()
        elif operation == "lvs":
            max_show = 20
            msg = gui.res.string_logical_volume_included % (vg)
            if len(lv_list) == 0:
                msg += gui.res.string_do_not
            else:
                for i in range(0, min(len(lv_list),max_show)):
                    if i > 0:
                        msg += ","
                    msg += lv_list[i]
                if i < len(lv_list) - 1:
                    msg += (gui.res.string_other % (len(lv_list) - max_show))
            dialogbox.messagebox.execute(msg)
コード例 #3
0
ファイル: launch_app.py プロジェクト: wbrxcorp/walbrix
def run_app(tmpdir, metadata, prefer_x11 = False):
	if os.path.isdir("%s/proc" % (tmpdir)):
		system.exec_shell("mount -o bind /proc %s/proc" % (tmpdir))

	if os.path.isdir("%s/dev" % (tmpdir)):
		if system.exec_shell("mount -o bind /dev %s/dev" % (tmpdir)) == 0:
			# chromiumが /dev/shmへのアクセスを要求するため
			os.chmod("%s/dev/shm" % (tmpdir), stat.S_IRWXO | stat.S_IRWXU | stat.S_IRWXG)
	if os.path.isdir("%s/sys" % (tmpdir)):
		system.exec_shell("mount -o bind /sys %s/sys" % (tmpdir))

	# /etc/localtimeがなければコピーする
	if not os.path.exists("%s/etc/localtime" % (tmpdir)):
		shutil.copyfile("/etc/localtime", "%s/etc/localtime" % (tmpdir))

	try:
		use_x11 = False
		if metadata != None:
			x11 = metadata.getroot().get("x11")
			if x11 == "required" or x11 == "recommended" or (prefer_x11 and x11 == "compatible"):
				use_x11 = True
		else:
			use_x11 = prefer_x11
		if use_x11:
			return system.exec_shell("xinit %s/sandbox %s -- -quiet" % (cli.wbui_path(), tmpdir))
		else:
			return system.exec_shell("%s/sandbox %s" % (cli.wbui_path(), tmpdir))
	finally:
		if os.path.ismount("%s/proc" % (tmpdir)):
			system.exec_shell("umount %s/proc" % (tmpdir))
		if os.path.ismount("%s/dev" % (tmpdir)):
			system.exec_shell("umount %s/dev" % (tmpdir))
		if os.path.ismount("%s/sys" % (tmpdir)):
			system.exec_shell("umount %s/sys" % (tmpdir))
コード例 #4
0
def run_app(tmpdir, metadata, prefer_x11=False):
    if os.path.isdir("%s/proc" % (tmpdir)):
        system.exec_shell("mount -o bind /proc %s/proc" % (tmpdir))

    if os.path.isdir("%s/dev" % (tmpdir)):
        if system.exec_shell("mount -o bind /dev %s/dev" % (tmpdir)) == 0:
            # chromiumが /dev/shmへのアクセスを要求するため
            os.chmod("%s/dev/shm" % (tmpdir),
                     stat.S_IRWXO | stat.S_IRWXU | stat.S_IRWXG)
    if os.path.isdir("%s/sys" % (tmpdir)):
        system.exec_shell("mount -o bind /sys %s/sys" % (tmpdir))

    # /etc/localtimeがなければコピーする
    if not os.path.exists("%s/etc/localtime" % (tmpdir)):
        shutil.copyfile("/etc/localtime", "%s/etc/localtime" % (tmpdir))

    try:
        use_x11 = False
        if metadata != None:
            x11 = metadata.getroot().get("x11")
            if x11 == "required" or x11 == "recommended" or (prefer_x11 and x11
                                                             == "compatible"):
                use_x11 = True
        else:
            use_x11 = prefer_x11
        if use_x11:
            return system.exec_shell("xinit %s/sandbox %s -- -quiet" %
                                     (cli.wbui_path(), tmpdir))
        else:
            return system.exec_shell("%s/sandbox %s" %
                                     (cli.wbui_path(), tmpdir))
    finally:
        if os.path.ismount("%s/proc" % (tmpdir)):
            system.exec_shell("umount %s/proc" % (tmpdir))
        if os.path.ismount("%s/dev" % (tmpdir)):
            system.exec_shell("umount %s/dev" % (tmpdir))
        if os.path.ismount("%s/sys" % (tmpdir)):
            system.exec_shell("umount %s/sys" % (tmpdir))