/usr/share/software-center/modify_review_gtk3.py is in software-center 13.10-0ubuntu4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | #! /usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2009 Canonical
#
# Authors:
# Michael Vogt
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from gi.repository import Gtk, GObject
GObject.threads_init()
import gettext
import locale
import logging
import logging.handlers
import os
import sys
from gettext import gettext as _
from optparse import OptionParser
import softwarecenter.paths
from softwarecenter.paths import SOFTWARE_CENTER_CACHE_DIR
from softwarecenter.db.database import Application
from softwarecenter.ui.gtk3.review_gui_helper import (
DeleteReviewApp,
ReportReviewApp,
SubmitReviewsApp,
SubmitUsefulnessApp,
)
#import httplib2
#httplib2.debuglevel = 1
if __name__ == "__main__":
try:
locale.setlocale(locale.LC_ALL, "")
except:
logging.exception("setlocale failed, resetting to C")
locale.setlocale(locale.LC_ALL, "C")
gettext.bindtextdomain("software-center", "/usr/share/locale")
gettext.textdomain("software-center")
if os.path.exists("./data/ui/gtk3/submit_review.ui"):
default_datadir = "./data"
else:
default_datadir = "/usr/share/software-center/"
# common options for optparse go here
parser = OptionParser()
parser.add_option("", "--datadir", default=default_datadir)
logfile_path = os.path.join(
SOFTWARE_CENTER_CACHE_DIR, "reviews-helper.log")
logfile_handler = logging.handlers.RotatingFileHandler(
logfile_path, maxBytes = 100 * 1000, backupCount = 5)
logfile_handler.setLevel(logging.INFO)
logging.getLogger().addHandler(logfile_handler)
logging.getLogger().addHandler(logging.StreamHandler())
# run review personality
if "submit_review" in sys.argv[0]:
# check options
parser.add_option("-a", "--appname")
parser.add_option("-p", "--pkgname")
parser.add_option("-i", "--iconname")
parser.add_option("-V", "--version")
parser.add_option("-O", "--origin")
parser.add_option("", "--parent-xid")
parser.add_option("", "--test", action="store_true", default=False)
parser.add_option("", "--debug",
action="store_true", default=False)
(options, args) = parser.parse_args()
softwarecenter.paths.datadir = options.datadir
if options.test:
options.pkgname = options.pkgname or 'apt'
options.appname = options.appname or 'Apt'
options.iconname = options.iconname or 'folder'
options.version = options.version or '1.0'
options.origin = options.origin or 'Ubuntu'
options.parent_xid = options.parent_xid or '1'
if not (options.pkgname and options.version):
parser.error(_("Missing arguments"))
if options.debug:
logging.basicConfig(level=logging.DEBUG)
# personality
logging.debug("submit_review mode")
# initialize and run
theapp = Application(options.appname, options.pkgname)
review_app = SubmitReviewsApp(datadir=options.datadir,
app=theapp,
parent_xid=options.parent_xid,
iconname=options.iconname,
origin=options.origin,
version=options.version)
review_app.run()
# run "report" personality
if "report_review" in sys.argv[0]:
# check options
parser.add_option("", "--review-id")
parser.add_option("", "--parent-xid")
parser.add_option("", "--debug",
action="store_true", default=False)
(options, args) = parser.parse_args()
softwarecenter.paths.datadir = options.datadir
if not (options.review_id):
parser.error(_("Missing review-id arguments"))
if options.debug:
logging.basicConfig(level=logging.DEBUG)
# personality
logging.debug("report_abuse mode")
# initialize and run
report_app = ReportReviewApp(datadir=options.datadir,
review_id=options.review_id,
parent_xid=options.parent_xid)
report_app.run()
if "submit_usefulness" in sys.argv[0]:
# check options
parser.add_option("", "--review-id")
parser.add_option("", "--parent-xid")
parser.add_option("", "--is-useful")
parser.add_option("", "--debug",
action="store_true", default=False)
(options, args) = parser.parse_args()
softwarecenter.paths.datadir = options.datadir
if not (options.review_id):
parser.error(_("Missing review-id arguments"))
if options.debug:
logging.basicConfig(level=logging.DEBUG)
# personality
logging.debug("report_abuse mode")
# initialize and run
usefulness_app = SubmitUsefulnessApp(datadir=options.datadir,
review_id=options.review_id,
parent_xid=options.parent_xid,
is_useful=int(options.is_useful))
usefulness_app.run()
if "delete_review" in sys.argv[0]:
#check options
parser.add_option("", "--review-id")
parser.add_option("", "--parent-xid")
parser.add_option("", "--debug",
action="store_true", default=False)
(options, args) = parser.parse_args()
softwarecenter.paths.datadir = options.datadir
if not (options.review_id):
parser.error(_("Missing review-id argument"))
if options.debug:
logging.basicConfig(level=logging.DEBUG)
logging.debug("delete review mode")
delete_app = DeleteReviewApp(datadir=options.datadir,
review_id=options.review_id,
parent_xid=options.parent_xid)
delete_app.run()
if "modify_review" in sys.argv[0]:
# check options
parser.add_option("", "--review-id")
parser.add_option("-i", "--iconname")
parser.add_option("", "--parent-xid")
parser.add_option("", "--debug",
action="store_true", default=False)
(options, args) = parser.parse_args()
softwarecenter.paths.datadir = options.datadir
if not (options.review_id):
parser.error(_("Missing review-id argument"))
if options.debug:
logging.basicConfig(level=logging.DEBUG)
# personality
logging.debug("modify_review mode")
# initialize and run
modify_app = SubmitReviewsApp(datadir=options.datadir,
app=None,
parent_xid=options.parent_xid,
iconname=options.iconname,
origin=None,
version=None,
action="modify",
review_id=options.review_id
)
modify_app.run()
# main
Gtk.main()
|