comparison frontends/src/quick_frontend/quick_utils.py @ 1290:faa1129559b8 frontends_multi_profiles

core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit): /!\ not finished, everything is still instable ! - bridge: DBus bridge has been modified to allow blocking call to be called in the same way as asynchronous calls - bridge: calls with a callback and no errback are now possible, default errback log the error - constants: removed hack to manage presence without OrderedDict, as an OrderedDict like class has been implemented in Libervia - core: getLastResource has been removed and replaced by getMainResource (there is a global better management of resources) - various style improvments: use of constants when possible, fixed variable overlaps, import of module instead of direct class import - frontends: printInfo and printMessage methods in (Quick)Chat are more generic (use of extra instead of timestamp) - frontends: bridge creation and option parsing (command line arguments) are now specified by the frontend in QuickApp __init__ - frontends: ProfileManager manage a more complete plug sequence (some stuff formerly manage in contact_list have moved to ProfileManager) - quick_frontend (quick_widgets): QuickWidgetsManager is now iterable (all widgets are then returned), or can return an iterator on a specific class (return all widgets of this class) with getWidgets - frontends: tools.jid can now be used in Pyjamas, with some care - frontends (XMLUI): profile is now managed - core (memory): big improvment on entities cache management (and specially resource management) - core (params/exceptions): added PermissionError - various fixes and improvments, check diff for more details
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:00:29 +0100
parents e3a9ea76de35
children 069ad98b360d
comparison
equal deleted inserted replaced
1289:653f2e2eea31 1290:faa1129559b8
15 # GNU Affero General Public License for more details. 15 # GNU Affero General Public License for more details.
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _
20 from os.path import exists, splitext 21 from os.path import exists, splitext
22 from optparse import OptionParser
21 23
22 def getNewPath(path): 24 def getNewPath(path):
23 """ Check if path exists, and find a non existant path if needed """ 25 """ Check if path exists, and find a non existant path if needed """
24 idx = 2 26 idx = 2
25 if not exists(path): 27 if not exists(path):
29 new_path = "%s_%d%s" % (root, idx, ext) 31 new_path = "%s_%d%s" % (root, idx, ext)
30 if not exists(new_path): 32 if not exists(new_path):
31 return new_path 33 return new_path
32 idx+=1 34 idx+=1
33 35
36 def check_options():
37 """Check command line options"""
38 usage = _("""
39 %prog [options]
40
41 %prog --help for options list
42 """)
43 parser = OptionParser(usage=usage) # TODO: use argparse
44
45 parser.add_option("-p", "--profile", help=_("Select the profile to use"))
46
47 (options, args) = parser.parse_args()
48 if options.profile:
49 options.profile = options.profile.decode('utf-8')
50 return options
51