summaryrefslogtreecommitdiffstats
path: root/usr/share/mageiawelcome/mageiawelcome.py
diff options
context:
space:
mode:
Diffstat (limited to 'usr/share/mageiawelcome/mageiawelcome.py')
-rw-r--r--usr/share/mageiawelcome/mageiawelcome.py263
1 files changed, 0 insertions, 263 deletions
diff --git a/usr/share/mageiawelcome/mageiawelcome.py b/usr/share/mageiawelcome/mageiawelcome.py
deleted file mode 100644
index 4e9bb8d..0000000
--- a/usr/share/mageiawelcome/mageiawelcome.py
+++ /dev/null
@@ -1,263 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import signal
-import os
-import time
-import subprocess
-import shlex
-import gettext
-import json
-import string
-import gi
-gi.require_version('Gtk', '3.0')
-from gi.repository import Gtk
-
-import sys
-
-PACKAGE_PARENT = '..'
-SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
-sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
-
-from webgui import start_gtk_thread
-from webgui import launch_browser
-from webgui import synchronous_gtk_message
-from webgui import kill_gtk_thread
-
-from helpers import *
-
-# i18n
-gettext.install("mageiawelcome")
-
-class Global(object):
- quit = False
- @classmethod
- def set_quit(cls, *args, **kwargs):
- cls.quit = True
-
-
-
-def main():
- start_gtk_thread()
- # Changing working directory
- abspath = os.path.abspath(__file__)
- dname = os.path.dirname(abspath)
- os.chdir(dname)
-
- #collect sys info
- #release = open("/etc/release", "r").read()
- release = subprocess.getoutput('lsb_release -sd')
- release = release[1:-1]
- release_nb = subprocess.getoutput('lsb_release -sr')
- release_nb = release_nb.strip()
- kernel = subprocess.getoutput('uname -r')
- if os.uname()[4] == 'x86_64':
- arch = '64-bit'
- else:
- arch = '32-bit'
- home = os.getenv("HOME")
- username = os.getenv("USER")
- try:
- desktop = get_desktop_name(os.path.basename(os.getenv("DESKTOP_SESSION")))
- except:
- desktop = 'Other'
-
- if desktop == 'Other':
- desktop = get_desktop_name2(os.getenv("XDG_CURRENT_DESKTOP"))
- if desktop == 'unknown':
- desktop = os.getenv("XDG_CURRENT_DESKTOP")
-
- #collect packages nad its status
- listapp = get_listapp()
-
- #TODO check if non-free and tainted enabled
- restricted_repos = "disabled"
-
-
- l={}
- l['name'] = _("Welcome to Mageia!")
- l['show'] = _("Show this window at startup")
- l['close'] = _("Close")
-
- l['release'] = release
- l['kernel_l'] = _("kernel:")
- l['kernel'] = kernel
- l['arch_l'] = _("arch:")
- l['arch'] = arch
- l['desktop_l'] = _("Desktop:")
- l['desktop'] = desktop
- l['welcome_btn'] = _("Welcome")
- l['welcome'] = _("Welcome<!--user//-->")
- l['user'] = username
- l['welcome_msg'] = _("<p>Thank you for choosing Mageia!</p><p>We have put in a lot of effort to provide you with the best possible system. We hope you will have a good experience with Mageia. If you feel that our project is a good idea, we would also appreciate any contribution you can make to it for next versions.</p><p>To find out how you can help <a class='weblink' href='https://www.mageia.org/contribute/'>click here</a>.</p><p>Don't forget to tell your friends about Mageia.</p>")
- l['mcc'] = _("Mageia Control Center")
- l['conf_update'] = _("Update system")
- l['inst_remove'] = _("Install and remove software")
- l['list_config'] = _("Summary of this configuration")
- l['go_further'] = _("To go further")
- l['h_documentation'] = _("Documentation")
- l['h_documentation_url'] = _("https://wiki.mageia.org/en/Documentation")
- l['features'] = _("New Features")
- # the {0} will be replaced by the release number
- l['mcc_url'] = _("https://doc.mageia.org/mcc/{0}/en/content/index.html").format(release_nb)
- l['relnotes'] = _("Release Notes")
- l['relnotes_url'] = _("https://wiki.mageia.org/en/Mageia_6_Release_Notes")
- l['errata'] = _("Errata")
- l['errata_url'] = _("https://wiki.mageia.org/en/Mageia_6_Errata")
- l['newcomers'] = _("Newcomers Howto")
- l['newcomers_url'] = _("https://wiki.mageia.org/en/Newcomers_start_here")
- l['h_support'] = _("Support")
- l['forum'] = _("Forums")
- l['forum_url'] = _("https://forums.mageia.org/en/")
- l['wiki'] = _("Wiki")
- l['wiki_url'] = _("https://wiki.mageia.org/en/Documentation")
- l['chat'] = _("Chat Room")
- l['bugs'] = _("Bugzilla")
- l['h_community'] = _("Community")
- l['comm_center'] = _("Community Center")
- l['contribute'] = _("Contribute")
- l['donate'] = _("Donations")
- l['joinus'] = _("Join us!")
- l['mccdesc'] = _("Mageia Control Center (aka drakconf) is a set of tools to help you configure your system")
- l['SM'] = _("Software Management")
- # the {0} will be replaced by the release number
- l['SM_url'] = _("https://doc.mageia.org/mcc/{0}/en/content/software-management.html").format(release_nb)
- l['Oa'] = _("Online administration")
- l['H'] = _("Hardware")
- l['NI'] = _("Network & Internet")
- l['S'] = _("System")
- l['NS'] = _("Network Sharing")
- l['LD'] = _("Local Disks")
- l['Sec'] = _("Security")
- l['B'] = _("Boot")
- l['adminpass'] = _("Administrator password is needed")
- l['userpass'] = _("User password is needed")
- l['conf_media'] = _("Configure media sources ...")
- l['mag_media'] = _("Mageia official repositories contain:")
- l['core'] = _("<span class='label green'>core</span> - the free-open-source packages, i.e. software licensed under a free-open-source license")
- l['nonfree'] = _("<span class='label red'>non-free</span> - some programs which are not free, or closed source. For example this repository includes Nvidia and ATI graphics card proprietary drivers, firmware for various WiFi cards, etc")
- l['tainted'] = _("<span class='label red'>tainted</span> - includes packages released under a free license. However, they may infringe on patents and copyright laws in some countries, e.g. multimedia codecs needed to play various audio/video files; packages needed to play commercial video DVD, etc. ")
- l['note'] = _("<strong>Note!</strong> non-free and tainted are not enabled by default.")
- l['editss'] = _("Edit software sources")
- l['updsys'] = _("... and update system")
- l['updpol'] = _("The Mageia's update policy is...")
- l['chkupd'] = _("Check system updates")
- l['guirpmdrake'] = _("GUI - RPMDrake")
- l['rpmdrake_desc'] = _("<span class='label green'>Rpmdrake</span> is a program for installing, uninstalling and updating packages. It is the graphical user interface of <span class='label green'>urpmi</span>")
- l['readmore'] = _("read more (wiki)")
- l['urpmi_url'] = _("https://wiki.mageia.org/en/URPMI")
- l['r_rpmdrake'] = _("RPMdrake")
- l['urpmi'] = _("URPMI - from command line")
- l['r_term'] = _("Terminal")
- l['small_selection'] = _("This is just small selection of popular packages, for more run")
- l['featured'] = _("Featured")
- l['games'] = _("Games")
- l['internet'] = _("Internet")
- l['video'] = _("Video")
- l['audio'] = _("Audio")
- l['office'] = _("Office")
- l['graphics'] = _("Graphics")
- l['system'] = _("System")
- l['programming'] = _("Programming")
- l['selected'] = _("Selected packages:")
- l['inst_sel'] = _("Install selected")
- l['youcan'] = _("You can always launch MageiaWelcome from menu")
-
- l['rpm_install'] = _("Applications")
- l['applist'] = listapp
- l['bodyclass'] = restricted_repos
- l['besure_repos'] = _("Be sure you have enabled <a>online repositories</a>")
-
-
- if os.path.exists(home + "/.mageiawelcome/norun.flag"):
- l['checked'] = ("")
- else:
- l['checked'] = ("CHECKED")
-
-
- l['home'] = home
-
-
- l['about'] = _("About")
-
- # Translations
-
- file = os.path.abspath('index.html')
- template = open(file).read()
- html = string.Template(template).safe_substitute(l)
-
- browser, web_recv, web_send = \
- synchronous_gtk_message(launch_browser)(html, quit_function=Global.set_quit)
-
- # Finally, here is our personalized main loop
-
- while not Global.quit:
-
- again = False
- msg = web_recv()
- if msg:
- msg = json.loads(msg)
- again = True
- if msg == "close":
- return 0
- elif msg == "checkbox checked":
- if os.path.exists(home + "/.mageiawelcome/norun.flag"):
- os.system("rm -rf " + home + "/.mageiawelcome/norun.flag")
- elif msg == "checkbox unchecked":
- os.system("mkdir -p " + home + "/.mageiawelcome")
- os.system("touch " + home + "/.mageiawelcome/norun.flag")
- elif msg.startswith("http"):
- subprocess.Popen(["xdg-open", msg])
- elif msg.startswith("irc"):
- subprocess.Popen(["xdg-open", msg])
- elif msg.startswith("run"):
- args = shlex.split(msg)
- args.pop(0)
- print(args)
- if args[0] == "xvt":
- os.chdir(home)
- subprocess.Popen(args)
-
- elif msg.startswith("gurpmi"):
- print(msg)
- args = shlex.split(msg)
- cat = args.pop(1)
- print(args)
- proc = subprocess.Popen(args, stdout=subprocess.PIPE)
- proc.wait()
- print(proc.returncode)
- if (proc.returncode == 0):
- listapp = get_listapp()
- web_send('$("ul#lista_applikacji").html("'+listapp+'");$("li#'+cat+'").trigger("click");')
- else: pass
- elif msg.startswith("install_selected"):
- print(msg)
- msg2 = msg.replace('install_selected','gurpmi')
- args = shlex.split(msg2)
- cat = args.pop(1)
- print(args)
- proc = subprocess.Popen(args, stdout=subprocess.PIPE)
- proc.wait()
- print(proc.returncode)
- if (proc.returncode == 0):
- listapp = get_listapp()
- web_send('$("ul#lista_applikacji").html("'+listapp+'");$("li#'+cat+'").trigger("click");')
- else: pass
- if again: pass
- else: time.sleep(0.1)
-
-
-def my_quit_wrapper(fun):
- signal.signal(signal.SIGINT, Global.set_quit)
- def fun2(*args, **kwargs):
- try:
- x = fun(*args, **kwargs) # equivalent to "apply"
- finally:
- kill_gtk_thread()
- Global.set_quit()
- return x
- return fun2
-
-
-if __name__ == '__main__': # <-- this line is optional
- my_quit_wrapper(main)()