Files
entropy/spritz/misc/spritz-uri-handler
T
2009-05-16 00:14:42 +02:00

40 lines
1.4 KiB
Python
Executable File

#!/usr/bin/python2
# Spritz (Entropy Interface)
# Copyright: (C) 2007-2009 Fabio Erculiani < lxnay<AT>sabayonlinux<DOT>org >
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
import sys, os
# working string: entropy://media-foo/abc;media-foo/abc2
spritz_path = "/usr/bin/spritz"
spritz_install_arg = "--install"
entropy_uri_pfx = "entropy://"
atoms = []
for arg in sys.argv[1:]:
if arg.startswith(entropy_uri_pfx):
uri_data = arg[len(entropy_uri_pfx):]
for atom in uri_data.split(";"):
atoms.append(atom)
elif arg == "--fetch":
atoms.append(arg)
if atoms:
args = [spritz_path, spritz_install_arg] + atoms
rc = os.system(' '.join(args))
raise SystemExit(rc)
raise SystemExit(1)