comparison frontends/src/jp/cmd_params.py @ 1015:fee00f2e11c2

memory, jp: added jp commands to load/save parameters template
author souliane <souliane@mailoo.org>
date Sun, 04 May 2014 18:43:54 +0200
parents
children 069ad98b360d
comparison
equal deleted inserted replaced
1014:e40d9858cb83 1015:fee00f2e11c2
1 #! /usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # jp: a SAT command line tool
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
6 # Copyright (C) 2013, 2014 Adrien Cossa (souliane@mailoo.org)
7
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21
22 import base
23 from sat.core.i18n import _
24
25 __commands__ = ["Params"]
26
27
28 class SaveTemplate(base.CommandBase):
29 def __init__(self, host):
30 super(SaveTemplate, self).__init__(host, 'save', use_profile=False, help=_('Save parameters template to xml file'))
31
32 def add_parser_options(self):
33 self.parser.add_argument("filename", type=str, help=_("Output file"))
34
35 def run(self):
36 """Save parameters template to xml file"""
37 if self.host.bridge.saveParamsTemplate(self.args.filename):
38 print _("Parameters saved to file %s") % self.args.filename
39 else:
40 print _("Can't save parameters to file %s") % self.args.filename
41
42
43 class LoadTemplate(base.CommandBase):
44
45 def __init__(self, host):
46 super(LoadTemplate, self).__init__(host, 'load', use_profile=False, help=_('Load parameters template from xml file'))
47
48 def add_parser_options(self):
49 self.parser.add_argument("filename", type=str, help=_("Input file"))
50
51 def run(self):
52 """Load parameters template from xml file"""
53 if self.host.bridge.loadParamsTemplate(self.args.filename):
54 print _("Parameters loaded from file %s") % self.args.filename
55 else:
56 print _("Can't load parameters from file %s") % self.args.filename
57
58
59 class Params(base.CommandBase):
60 subcommands = (SaveTemplate, LoadTemplate)
61
62 def __init__(self, host):
63 super(Params, self).__init__(host, 'params', use_profile=False, help=_('Save/load parameters template'))