~elementary-os/ubuntu-package-imports/software-properties-bionic

1 by RabbitBot
Initial import, version 0.96.24.26
1
#!/usr/bin/env python3
2
#  software-properties - graphical abstraction of the sources.list
3
#  
4
#  Copyright (c) 2004,2005 Canonical
5
#                2004,2005 Michiel Sikkes
6
#  
7
#  Author: Michiel Sikkes <michiel@eyesopened.nl>
8
#          Michael Vogt <mvo@debian.org>
9
# 
10
#  This program is free software; you can redistribute it and/or 
11
#  modify it under the terms of the GNU General Public License as 
12
#  published by the Free Software Foundation; either version 2 of the
13
#  License, or (at your option) any later version.
14
# 
15
#  This program is distributed in the hope that it will be useful,
16
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
#  GNU General Public License for more details.
19
# 
20
#  You should have received a copy of the GNU General Public License
21
#  along with this program; if not, write to the Free Software
22
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
#  USA
24
25
import gettext
26
import os
27
import sys
28
import locale
29
30
from optparse import OptionParser
31
32
import aptsources
33
from aptsources.sourceslist import SourcesList
34
35
#sys.path.append("@prefix@/share/update-manager/python")
36
37
from softwareproperties.gtk.SoftwarePropertiesGtk import SoftwarePropertiesGtk
38
39
if __name__ == "__main__":
40
  _ = gettext.gettext
41
 
42
  # Begin parsing of options
43
  parser = OptionParser()
44
  parser.add_option ("-d", "--debug", action="store_true",
45
                     dest="debug", default=False,
46
                     help="Print some debug information to the command line")
47
  parser.add_option ("-m", "--massive-debug", action="store_true",
48
                     dest="massive_debug", default=False,
49
                     help="Print a lot of debug information to the "
50
                          "command line")
51
  parser.add_option ("-n", "--no-update", action="store_true",
52
                     dest="no_update", default=False,
53
                     help="No update on repository change (useful if called "\
54
                     "from an external program).")
55
  parser.add_option("-t", "--toplevel", 
56
                    action="store", type="string", dest="toplevel",
57
                    help="Set x-window-id of the toplevel parent for the "\
58
                    "dialog (useful for embedding)")
59
  parser.add_option("-e", "--enable-component",
60
                    action="store", type="string", dest="enable_component",
61
                    help="Enable the specified component of the distro's "\
62
                    "repositories")
63
  parser.add_option("--open-tab", "",
64
                    action="store", type="string", default=None,
65
                    help="Open specific tab number on startup")
66
  parser.add_option("--enable-ppa", "",
67
                    action="store", type="string", default=None,
68
                    help="Enable PPA with the given name")
69
  parser.add_option("-k", "--keyserver",
70
                    dest="keyserver", default="",
71
                    help="Legacy option, unused")
72
  parser.add_option("--data-dir", "",
73
                    action="store", type="string", default="/usr/share/software-properties/",
74
                    help="Use data files (UI) from the given directory")
75
  
76
  (options, args) = parser.parse_args()
77
                     
78
  try:
79
      locale.setlocale(locale.LC_ALL, '')
80
  except locale.Error as e:
81
      sys.stderr.write('Cannot set locale: %s\n' % str(e))
82
  localesApp="software-properties"
83
  gettext.textdomain(localesApp)
84
85
  # force new files to be 644 (LP: #497778)
86
  os.umask(0o022)
87
88
  file = None
89
  if len(args) > 0:
90
    file = args[0]
91
  if options.enable_ppa:
92
    app = SoftwarePropertiesGtk(datadir=options.data_dir, options=options, file=file)
93
    app.add_source_from_line("ppa:%s" % options.enable_ppa)
94
    app.sourceslist.save()
95
  elif options.enable_component:
96
    print(_("The --enable-component/-e command-line switch has been deprecated. "
97
            "Instead of 'software-properties-gtk -e multiverse' you can use \n'add-apt-repository multiverse'"))
98
    sys.exit(1)
99
  else:
100
    app = SoftwarePropertiesGtk(datadir=options.data_dir, options=options, file=file)
101
    app.run()
102
    sys.exit(app.modified_sourceslist)