Ejemplo n.º 1
0
    def __get_cli_options(self):
        """Get options passed in at the command line"""
        shortOptions = "htdp:vc:va:vl:v"
        longOptions = ["help", "timer", "debug", "path=", "config=", "auto=", "language="]
        try:
            opts, args = getopt.getopt(sys.argv[1:], shortOptions, longOptions)
        except getopt.GetoptError as err:
            # print help information and exit:
            print(str(err))
            sys.exit(2)

        # set options
        path = False
        configFilePath = False

        if sys.argv[1:] != [] and opts == []:
            path = ''
            for chunk in sys.argv[1:]:
                path += chunk + ' '

        for o, a in opts:
            # show processing times
            if o in ("-t", "--timer"):
                app.showTimes = True
                print("Showing processing times")
            # show debug messages
            elif o in ("-d", "--debug"):
                app.debug = True
                print("Running in debug mode")
                print("Version : " + app.version)
                print("Python %s, wxPython %s" % (platform.python_version(), utils.get_wxversion()))
            # set path
            elif o in ("-p", "--path"):
                path = self.strip_leading(a)
            # show help and exit
            elif o in ("-h", "--help"):
                self.usage()
            # use a config path
            elif o in ("-c", "--config"):
                configFilePath = self.strip_leading(a)
        # set auto level
            elif o in ("-a", "--auto"):
                level = self.strip_leading(a)
                if level not in ('0', '1', '2', '3'):
                    exit("Invalid auto mode level : '%s'" % level)
                elif not configFilePath:
                    exit("Auto mode level must be used with configuration file ( '-c' or '--config' option )")
                else:
                    print("Auto mode level set : %s" % level)
                    app.autoModeLevel = int(level)
        # specify the language
            elif o in ("-l", "--language"):
                app.language = self.strip_leading(a)
        return path, configFilePath
Ejemplo n.º 2
0
    def __get_cli_options(self):
        """Get options passed in at the command line"""
        shortOptions = "htdp:vc:va:vl:v"
        longOptions = ["help", "timer", "debug", "path=", "config=", "auto=", "language="]
        try:
            opts, args = getopt.getopt(sys.argv[1:], shortOptions, longOptions)
        except getopt.GetoptError as err:
            # print help information and exit:
            print(str(err))
            sys.exit(2)

        # set options
        path = False
        configFilePath = False

        if sys.argv[1:] != [] and opts == []:
            path = ''
            for chunk in sys.argv[1:]:
                path += chunk + ' '

        for o, a in opts:
            # show processing times
            if o in ("-t", "--timer"):
                app.showTimes = True
                print("Showing processing times")
            # show debug messages
            elif o in ("-d", "--debug"):
                app.debug = True
                print("Running in debug mode")
                print("Version : " + app.version)
                print("Python %s, wxPython %s" % (platform.python_version(), utils.get_wxversion()))
            # set path
            elif o in ("-p", "--path"):
                path = self.strip_leading(a)
            # show help and exit
            elif o in ("-h", "--help"):
                self.usage()
            # use a config path
            elif o in ("-c", "--config"):
                configFilePath = self.strip_leading(a)
        # set auto level
            elif o in ("-a", "--auto"):
                level = self.strip_leading(a)
                if level not in ('0', '1', '2', '3'):
                    exit("Invalid auto mode level : '%s'" % level)
                elif not configFilePath:
                    exit("Auto mode level must be used with configuration file ( '-c' or '--config' option )")
                else:
                    print("Auto mode level set : %s" % level)
                    app.autoModeLevel = int(level)
        # specify the language
            elif o in ("-l", "--language"):
                app.language = self.strip_leading(a)
        return path, configFilePath
Ejemplo n.º 3
0
    def __init_ctrls(self, parent):
        wx.Dialog.__init__(self, id=wxID_ABOUT, name=u'About', parent=parent,
                style=wx.DEFAULT_DIALOG_STYLE,
                title=_(u"About Metamorphose"))
        self.SetIcon(wx.Icon(utils.icon_path(u'about.ico'), wx.BITMAP_TYPE_ICO))

        fontParams = app.fontParams
        fontSize = fontParams['size']
        fontFamily = fontParams['family']
        fontStyle = fontParams['style']

        self.SetFont(wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False, u'Times New Roman'))
        self.Center(wx.HORIZONTAL | wx.VERTICAL)
        self.SetThemeEnabled(True)

        self.greet = wx.StaticText(id=wxID_ABOUTGREET,
                                   label=u"Métamorphose 2", name=u'greet', parent=self)
        self.greet.SetFont(wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False))

        self.CLOSE = wx.BitmapButton(id=wxID_ABOUTCLOSE,
                                     bitmap=wx.Bitmap(utils.icon_path(u'metamorphose128.png'), wx.BITMAP_TYPE_PNG),
                                     name=u'CLOSE', parent=self, style=wx.BU_AUTODRAW)
        self.CLOSE.SetToolTipString(_(u"Click here to exit"))
        self.CLOSE.Bind(wx.EVT_BUTTON, self.on_close_button, id=wxID_ABOUTCLOSE)

        self.copyright = wx.StaticText(id=wxID_ABOUTCOPYRIGHT,
                                       label=u"Copyright © 2006-2015 Ianaré Sévi", name=u'copyright',
                                       parent=self)
        self.copyright.SetFont(wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.version = wx.StaticText(id=wxID_ABOUTVERSION,
                                     label=_(u"Version: %s") % app.version,
                                     name=u'version', parent=self)
        self.version.SetFont(wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.wxVersion = wx.StaticText(id=wxID_ABOUTWXVERSION,
                                       label=_(u"Using Python %s, wxPython %s") % (
                                           platform.python_version(),
                                           utils.get_wxversion()
                                       ),
                                       name=u'version', parent=self)
        self.wxVersion.SetFont(wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False))

        self.link = hl.HyperLinkCtrl(self, wxID_ABOUTLINK, _(u"Metamorphose Home Page"),
                                     URL=u'http://file-folder-ren.sourceforge.net/', style=0)

        self.bugReport = hl.HyperLinkCtrl(self, wxID_ABOUTLINK, _(u"GitHub Project Page"),
                                          URL=u'https://github.com/metamorphose/metamorphose2')
        self.bugReport.Show(True)

        self.donateButton = wx.Button(id=wxID_PANELDONATEBUTTON,
                                      label=_(u"Donate"), name=u'donateButton', parent=self)
        self.donateButton.SetFont(wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False,
                                          u'Times New Roman'))
        self.donateButton.Bind(wx.EVT_BUTTON, self.on_donate_button,
                               id=wxID_PANELDONATEBUTTON)

        self.donate = hl.HyperLinkCtrl(self, wxID_ABOUTDONATE, _(u"Donate"),
                                       URL=u'http://sourceforge.net/donate/index.php?group_id=146403')
        self.donate.Show(False)

        self.licenseButton = wx.Button(id=wxID_PANELLICENSEBUTTON,
                                       label=_(u"License"), name=u'licenseButton', parent=self)
        self.licenseButton.Bind(wx.EVT_BUTTON, self.show_small_help,id=wxID_PANELLICENSEBUTTON)

        self.creditsButton = wx.Button(id=wxID_PANELCREDITSBUTTON,
                                       label=_(u"Credits"), name=u'licenseButton', parent=self)
        self.creditsButton.Bind(wx.EVT_BUTTON, self.show_small_help,id=wxID_PANELCREDITSBUTTON)
Ejemplo n.º 4
0
    def __init__(self, prnt, options):
        # Important variables needed throughout the application classes
        self.warn = [] # warnings
        self.bad = [] # errors
        self.errorLog = [] # all errors go here
        self.items = [] # items to rename
        self.spacer = u" " * 6 # spacer for status messages (to clear image)

        wx.Frame.__init__(self, id=wxID_MAIN_WINDOW, name=u'MainWindow',
                          parent=prnt, style=wx.DEFAULT_FRAME_STYLE)

        # first run?
        utils.init_environment()

        self.set_language()

        app.debug_print("Operating System: %s - %s - %s" % (platform.system(), platform.release(), platform.version()))
        app.debug_print("System encoding: " + self.encoding)
        app.debug_print("Python version: " + platform.python_version())
        app.debug_print("wxPython version: " + utils.get_wxversion())
        app.debug_print("Interface language: " + app.language)

        # import these modules here since they need language settings activated
        global renamer
        import renamer
        global configs
        import configs
        global picker
        import picker
        global bottomWindow
        import bottomWindow

        # initialize preferences
        app.prefs = preferences.Methods()

        # icons used for status bar messages
        self.statusImages = {
            u'failed': wx.Bitmap(utils.icon_path(u'failed_sb.ico'),
                                 wx.BITMAP_TYPE_ICO),
            u'wait': wx.Bitmap(utils.icon_path(u'wait.png'),
                               wx.BITMAP_TYPE_PNG),
            u'warn': wx.Bitmap(utils.icon_path(u'warn_sb.ico'),
                               wx.BITMAP_TYPE_ICO),
            u'complete': wx.Bitmap(utils.icon_path(u'complete.ico'),
                                   wx.BITMAP_TYPE_ICO),
            u'eyes': wx.Bitmap(utils.icon_path(u'eyes.png'),
                               wx.BITMAP_TYPE_PNG),
            }
        # build main GUI
        self.__init_ctrls(prnt)

        # clear undo if set in preferences:
        if app.prefs.get(u'clearUndo'):
            try:
                originalFile = codecs.open(utils.get_user_path(u'undo/original.bak'),
                                           'w', "utf-8")
                originalFile.write('')
                renamedFile = codecs.open(utils.get_user_path(u'undo/renamed.bak'),
                                          'w', "utf-8")
                renamedFile.write('')
            except IOError, error:
                utils.make_err_msg(_(u"%s\n\nCould not clear undo") % error,
                                   _(u"Error"))
                pass
Ejemplo n.º 5
0
 def usage(self):
     """Print CLI usage and options to screen."""
     print()
     print("Metamorphose 2.%s\nRunning on Python %s, wxPython %s" % (app.version, platform.python_version(), utils.get_wxversion()))
     print("Copyright (C) 2006-2014 ianare sevi")
     print("<http://file-folder-ren.sourceforge.net/>\n")
     print("Metamorphose is a graphical mass renaming program for files and folders.")
     print("There is support for automating GUI tasks via command line.\n")
     print("metamorphose2 [/path/to/open/spaces ok]")
     print("metamorphose2 [-t] [-d] [-p /path/to/open] [[-c /path/to/file.cfg] [-a level (0-3)]] [-l language]")
     print()
     print("-h,  --help       Show help screen and exit.")
     print("-t,  --timer      Show time taken to complete operations.")
     print("-d,  --debug      Show debugging information.")
     print("-p=, --path       Specify a directory to load.")
     print("-c=, --config     Specify a configuration file to load.")
     print("-a=, --auto       Specify automatic mode level to use with configuration file:")
     print("                    0 = do not preview items")
     print("                    1 = auto preview items")
     print("                    2 = auto rename items")
     print("                    3 = auto rename items and exit on success")
     print("-l=, --language  Overide prefered language :")
     print("                    en_US")
     print("                    fr")
     print()
     print("If no other options are given, you may specify a path to open:")
     print("$ metamorphose2 /srv/samba/Windows Likes Spaces")
     print()
     sys.exit()
Ejemplo n.º 6
0
 def usage(self):
     """Print CLI usage and options to screen."""
     print()
     print("Metamorphose 2.%s\nRunning on Python %s, wxPython %s" % (app.version, platform.python_version(), utils.get_wxversion()))
     print("Copyright (C) 2006-2014 ianare sevi")
     print("<http://file-folder-ren.sourceforge.net/>\n")
     print("Metamorphose is a graphical mass renaming program for files and folders.")
     print("There is support for automating GUI tasks via command line.\n")
     print("metamorphose2 [/path/to/open/spaces ok]")
     print("metamorphose2 [-t] [-d] [-p /path/to/open] [[-c /path/to/file.cfg] [-a level (0-3)]] [-l language]")
     print()
     print("-h,  --help       Show help screen and exit.")
     print("-t,  --timer      Show time taken to complete operations.")
     print("-d,  --debug      Show debugging information.")
     print("-p=, --path       Specify a directory to load.")
     print("-c=, --config     Specify a configuration file to load.")
     print("-a=, --auto       Specify automatic mode level to use with configuration file:")
     print("                    0 = do not preview items")
     print("                    1 = auto preview items")
     print("                    2 = auto rename items")
     print("                    3 = auto rename items and exit on success")
     print("-l=, --language  Overide prefered language :")
     print("                    en_US")
     print("                    fr")
     print()
     print("If no other options are given, you may specify a path to open:")
     print("$ metamorphose2 /srv/samba/Windows Likes Spaces")
     print()
     sys.exit()
Ejemplo n.º 7
0
    def __init_ctrls(self, parent):
        wx.Dialog.__init__(self,
                           id=wxID_ABOUT,
                           name=u'About',
                           parent=parent,
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=_(u"About Metamorphose"))
        self.SetIcon(wx.Icon(utils.icon_path(u'about.ico'),
                             wx.BITMAP_TYPE_ICO))

        fontParams = app.fontParams
        fontSize = fontParams['size']
        fontFamily = fontParams['family']
        fontStyle = fontParams['style']

        self.SetFont(
            wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False,
                    u'Times New Roman'))
        self.Center(wx.HORIZONTAL | wx.VERTICAL)
        self.SetThemeEnabled(True)

        self.greet = wx.StaticText(id=wxID_ABOUTGREET,
                                   label=u"Métamorphose 2",
                                   name=u'greet',
                                   parent=self)
        self.greet.SetFont(
            wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False))

        self.CLOSE = wx.BitmapButton(
            id=wxID_ABOUTCLOSE,
            bitmap=wx.Bitmap(utils.icon_path(u'metamorphose128.png'),
                             wx.BITMAP_TYPE_PNG),
            name=u'CLOSE',
            parent=self,
            style=wx.BU_AUTODRAW)
        self.CLOSE.SetToolTipString(_(u"Click here to exit"))
        self.CLOSE.Bind(wx.EVT_BUTTON,
                        self.on_close_button,
                        id=wxID_ABOUTCLOSE)

        self.copyright = wx.StaticText(
            id=wxID_ABOUTCOPYRIGHT,
            label=u"Copyright © 2006-2013 Ianaré Sévi",
            name=u'copyright',
            parent=self)
        self.copyright.SetFont(
            wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.version = wx.StaticText(id=wxID_ABOUTVERSION,
                                     label=_(u"Version: %s") % app.version,
                                     name=u'version',
                                     parent=self)
        self.version.SetFont(
            wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.wxVersion = wx.StaticText(
            id=wxID_ABOUTWXVERSION,
            label=_(u"Using Python %s, wxPython %s") %
            (platform.python_version(), utils.get_wxversion()),
            name=u'version',
            parent=self)
        self.wxVersion.SetFont(
            wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False))

        self.link = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTLINK,
            _(u"Metamorphose Home Page"),
            URL=u'http://file-folder-ren.sourceforge.net/',
            style=0)

        self.bugReport = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTLINK,
            _(u"GitHub Project Page"),
            URL=u'https://github.com/metamorphose/metamorphose2')
        self.bugReport.Show(True)

        self.donateButton = wx.Button(id=wxID_PANELDONATEBUTTON,
                                      label=_(u"Donate"),
                                      name=u'donateButton',
                                      parent=self)
        self.donateButton.SetFont(
            wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False,
                    u'Times New Roman'))
        self.donateButton.Bind(wx.EVT_BUTTON,
                               self.on_donate_button,
                               id=wxID_PANELDONATEBUTTON)

        self.donate = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTDONATE,
            _(u"Donate"),
            URL=u'http://sourceforge.net/donate/index.php?group_id=146403')
        self.donate.Show(False)

        self.licenseButton = wx.Button(id=wxID_PANELLICENSEBUTTON,
                                       label=_(u"License"),
                                       name=u'licenseButton',
                                       parent=self)
        self.licenseButton.Bind(wx.EVT_BUTTON,
                                self.show_small_help,
                                id=wxID_PANELLICENSEBUTTON)

        self.creditsButton = wx.Button(id=wxID_PANELCREDITSBUTTON,
                                       label=_(u"Credits"),
                                       name=u'licenseButton',
                                       parent=self)
        self.creditsButton.Bind(wx.EVT_BUTTON,
                                self.show_small_help,
                                id=wxID_PANELCREDITSBUTTON)