Files
entropy/sulfur/misc/sulfur-uri-handler
2009-05-17 10:24:37 +02:00

43 lines
1.5 KiB
Python
Executable File

#!/usr/bin/python2
# Sulfur (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
sulfur_path = "/usr/bin/sulfur"
sulfur_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(";"):
if atom.endswith("/"):
atom = atom[:-1]
atoms.append(atom)
elif arg == "--fetch":
atoms.append(arg)
if atoms:
args = [sulfur_path, sulfur_install_arg] + atoms
print ' '.join(args)
rc = os.system(' '.join(args))
raise SystemExit(rc)
raise SystemExit(1)