Ejemplo n.º 1
0
    def install(cls, import_defaults=True):
	# copy default template files to user_dir
	templates = ['example.csv', 'example.csv']
        base_dir = os.path.join(paths.lib_dir(), "plugins", "report", 'mako')
	for template in templates:
	    f = os.path.join(paths.user_dir(), template)
	    if not os.path.exists(f):
		shutil.copy(os.path.join(base_dir, template), f)
Ejemplo n.º 2
0
 def install(cls, import_defaults=True):
     logger.debug("installing mako plugin")
     # copy default template files to user_dir
     templates = ["example.csv", "example.csv"]
     base_dir = os.path.join(paths.lib_dir(), "plugins", "report", "mako")
     for template in templates:
         f = os.path.join(paths.user_dir(), template)
         if not os.path.exists(f):
             shutil.copy(os.path.join(base_dir, template), f)
Ejemplo n.º 3
0
 def install(cls, import_defaults=True):
     logger.debug("installing mako plugin")
     # copy default template files to user_dir
     templates = ['example.csv', 'example.csv']
     base_dir = os.path.join(paths.lib_dir(), "plugins", "report", 'mako')
     for template in templates:
         f = os.path.join(paths.user_dir(), template)
         if not os.path.exists(f):
             shutil.copy(os.path.join(base_dir, template), f)
Ejemplo n.º 4
0
 def install(cls, import_defaults=True):
     # copy default template files to user_dir
     templates = ['basic.xsl', 'labels.xsl', 'plant_list.xsl',
                  'plant_list_ex.xsl', 'small_labels.xsl']
     base_dir = os.path.join(paths.lib_dir(), "plugins", "report", 'xsl')
     for template in templates:
         f = os.path.join(paths.user_dir(), template)
         if not os.path.exists(f):
             shutil.copy(os.path.join(base_dir, template), f)
Ejemplo n.º 5
0
def _default_handler():
    import bauble.paths as paths
    if _main_is_frozen():
        filename = os.path.join(paths.user_dir(), 'bauble.log')
        handler = logging.FileHandler(filename, 'w+')
        sys.stdout = open(filename, 'w+')
        sys.stderr = open(filename, 'w+')
    else:
        handler = logging.StreamHandler()
    return handler
Ejemplo n.º 6
0
 def set_filename(self, filename):
     if not filename:
         self._filename = None
         self.dialog.set_filename('')
         self.dialog.set_current_folder(paths.user_dir())
         self.props.label = self._default_label
     else:
         self._filename = filename
         head, tail = os.path.split(self._filename)
         self.dialog.set_filename(self._filename)
         self.props.label = tail
Ejemplo n.º 7
0
 def set_filename(self, filename):
     if not filename:
         self._filename = None
         self.dialog.set_filename('')
         self.dialog.set_current_folder(paths.user_dir())
         self.props.label = self._default_label
     else:
         self._filename = filename
         head, tail = os.path.split(self._filename)
         self.dialog.set_filename(self._filename)
         self.props.label = tail
Ejemplo n.º 8
0
 def get_params(self, new=None):
     if new is not None:
         self.dbtype = "SQLite"
         self.use_defaults = True
     if self.dbtype == "SQLite":
         if self.use_defaults is True:
             name = new or self.connection_name
             self.filename = os.path.join(paths.user_dir(), name + ".db")
             self.pictureroot = os.path.join(paths.user_dir(), name)
         result = {"file": self.filename, "default": self.use_defaults, "pictures": self.pictureroot}
     else:
         result = {
             "db": self.database,
             "host": self.host,
             "user": self.user,
             "pictures": self.pictureroot,
             "passwd": self.passwd,
         }
     result["type"] = self.dbtype
     return result
Ejemplo n.º 9
0
 def install(cls, import_defaults=True):
     # copy default template files to user_dir
     templates = [
         'basic.xsl', 'labels.xsl', 'plant_list.xsl', 'plant_list_ex.xsl',
         'small_labels.xsl'
     ]
     base_dir = os.path.join(paths.lib_dir(), "plugins", "report", 'xsl')
     for template in templates:
         f = os.path.join(paths.user_dir(), template)
         if not os.path.exists(f):
             shutil.copy(os.path.join(base_dir, template), f)
Ejemplo n.º 10
0
 def get_parameters(self):
     d = {}
     invalid_chars = ', "\'():;'
     if self.default_check.get_active():
         name = self.conn_mgr_ref()._get_connection_name()
         from string import maketrans
         fixed = name.translate(maketrans(invalid_chars,
                                          '_'*len(invalid_chars)))
         d['file'] = os.path.join(paths.user_dir(), '%s.db' % fixed)
     else:
         d['file'] = self.file_entry.get_text()
     return d
Ejemplo n.º 11
0
 def get_parameters(self):
     d = {}
     invalid_chars = ', "\'():;'
     if self.default_check.get_active():
         name = self.conn_mgr_ref()._get_connection_name()
         from string import maketrans
         fixed = name.translate(
             maketrans(invalid_chars, '_' * len(invalid_chars)))
         d['file'] = os.path.join(paths.user_dir(), '%s.db' % fixed)
     else:
         d['file'] = self.file_entry.get_text()
     d['pictures'] = self.pictureroot_entry.get_text()
     return d
Ejemplo n.º 12
0
 def get_params(self, new=None):
     if new is not None:
         self.dbtype = 'SQLite'
         self.use_defaults = True
     if self.dbtype == 'SQLite':
         if self.use_defaults is True:
             name = new or self.connection_name
             self.filename = os.path.join(
                 paths.user_dir(), name + '.db')
             self.pictureroot = os.path.join(
                 paths.user_dir(), name)
         result = {'file': self.filename,
                   'default': self.use_defaults,
                   'pictures': self.pictureroot}
     else:
         result = {'db': self.database,
                   'host': self.host,
                   'user': self.user,
                   'pictures': self.pictureroot,
                   'passwd': self.passwd,
                   }
     result['type'] = self.dbtype
     return result
Ejemplo n.º 13
0
 def __init__(self, dialog_parent):
     super(FileChooserButton, self).__init__(self._default_label)
     self._filename = False
     self.props.use_underline = False
     self.props.xalign = 0
     self.dialog = \
         gtk.FileChooserDialog(title=_('Select a stylesheet'),
                               parent=dialog_parent,
                               buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,
                                        gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     self.dialog.set_select_multiple(False)
     self.dialog.set_current_folder(paths.user_dir())
     self.dialog.connect('response', self._on_response)
     self.connect('clicked', self._on_clicked)
Ejemplo n.º 14
0
 def __init__(self, dialog_parent):
     super(FileChooserButton, self).__init__(self._default_label)
     self._filename = False
     self.props.use_underline = False
     self.props.xalign = 0
     self.dialog = \
         gtk.FileChooserDialog(title=_('Select a stylesheet'),
                               parent=dialog_parent,
                               buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,
                                        gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     self.dialog.set_select_multiple(False)
     self.dialog.set_current_folder(paths.user_dir())
     self.dialog.connect('response', self._on_response)
     self.connect('clicked', self._on_clicked)
Ejemplo n.º 15
0
 def get_params(self, new=None):
     if new is not None:
         self.dbtype = 'SQLite'
         self.use_defaults = True
     if self.dbtype == 'SQLite':
         if self.use_defaults is True:
             name = new or self.connection_name
             self.filename = os.path.join(
                 paths.user_dir(), name + '.db')
             self.pictureroot = os.path.join(
                 paths.user_dir(), name)
         result = {'file': self.filename,
                   'default': self.use_defaults,
                   'pictures': self.pictureroot}
     else:
         result = {'db': self.database,
                   'host': self.host,
                   'user': self.user,
                   'pictures': self.pictureroot,
                   'passwd': self.passwd,
                   }
     result['type'] = self.dbtype
     return result
Ejemplo n.º 16
0
using a dictionary like interface. e.g. ::

    import bauble.prefs
    prefs.prefs[key] = value
"""

# TODO: maybe we should have a create method that creates the preferences
# todo a one time thing if the files doesn't exist

# TODO: Consider using ConfigObj since it does validation, type
# conversion and unicode automatically...the cons are that it adds
# another dependency and we would have to change the prefs interface
# throughout bauble

default_filename = 'config'
default_prefs_file = os.path.join(paths.user_dir(), default_filename)
"""
The default file for the preference settings file.
"""

config_version_pref = 'bauble.config.version'
"""
The preferences key for the bauble version of the preferences file.
"""

config_version = bauble.version_tuple[0], bauble.version_tuple[1]

date_format_pref = 'bauble.default_date_format'
"""
The preferences key for the default data format.
"""
Ejemplo n.º 17
0
 def on_help_menu_logfile(self, widget, data=None):
     filename = os.path.join(paths.user_dir(), 'bauble.log')
     desktop.open(filename, dialog_on_error=True)
Ejemplo n.º 18
0
 def on_help_menu_logfile(self, widget, data=None):
     filename = os.path.join(paths.user_dir(), 'bauble.log')
     desktop.open(filename, dialog_on_error=True)
Ejemplo n.º 19
0
import bauble.view as view
from bauble.plugins.plants import Species

PICASA_TOKEN_KEY = u'picasa_token'

# TODO: should we store the email and album in the BaubleMeta...these
# should only be changeable by an administrator...should probably only
# allow an administrator to even access the PicasaTool
PICASA_EMAIL_KEY = u'picasa_email'
PICASA_ALBUM_KEY = u'picasa_album'

# see http://code.google.com/apis/picasaweb/reference.html#Parameters
picasa_imgmax = 'd'  # "d" means download the original
picasa_thumbsize = '144u'

default_path = os.path.join(paths.user_dir(), 'photos')

# keep a copy of the feeds that we retrieve by tag
__feed_cache = {}


def update_meta(email=None, album=None, token=None):
    """
    Update the email, album and authorization token in the bauble meta table.
    """
    # TODO: should we allow setting the values to None
    session = db.Session()
    if email:
        email = utils.utf8(email)
        meta.get_default(PICASA_EMAIL_KEY, email, session).value = email
    if album:
Ejemplo n.º 20
0
from bauble.plugins.plants import Species
from bauble.utils.log import debug

PICASA_TOKEN_KEY = u'picasa_token'

# TODO: should we store the email and album in the BaubleMeta...these
# should only be changeable by an administrator...should probably only
# allow an administrator to even access the PicasaTool
PICASA_EMAIL_KEY = u'picasa_email'
PICASA_ALBUM_KEY = u'picasa_album'

# see http://code.google.com/apis/picasaweb/reference.html#Parameters
picasa_imgmax = 'd' # "d" means download the original
picasa_thumbsize = '144u'

default_path = os.path.join(paths.user_dir(), 'photos')

# keep a copy of the feeds that we retrieve by tag
__feed_cache = {}


def update_meta(email=None, album=None, token=None):
    """
    Update the email, album and authorization token in the bauble meta table.
    """
    # TODO: should we allow setting the values to None
    session = db.Session()
    if email:
        email = utils.utf8(email)
        meta.get_default(PICASA_EMAIL_KEY, email, session).value = email
    if album:
Ejemplo n.º 21
0
    """
    # TODO: it would be nice to show a Tk dialog here saying we can't
    # import gtk...but then we would have to include all of the Tk libs in
    # with the win32 batteries-included installer
    try:
        import gtk
        import gobject
    except ImportError, e:
        print _('** Error: could not import gtk and/or gobject')
        print e
        if sys.platform == 'win32':
            print _('Please make sure that GTK_ROOT\\bin is in your PATH.')
        sys.exit(1)

    # create the user directory
    if not os.path.exists(paths.user_dir()):
        os.makedirs(paths.user_dir())

    # add console root handler, and file root handler, set it at the logging
    # level specified by BAUBLE_LOGGING, or at INFO level.
    filename = os.path.join(paths.user_dir(), 'bauble.log')
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fileHandler = logging.FileHandler(filename, 'w+')
    logging.getLogger().addHandler(fileHandler)
    consoleHandler = logging.StreamHandler()
    logging.getLogger().addHandler(consoleHandler)
    fileHandler.setFormatter(formatter)
    consoleHandler.setFormatter(formatter)
    fileHandler.setLevel(logging.DEBUG)
    consoleHandler.setLevel(consoleLevel)
Ejemplo n.º 22
0
    """
    # TODO: it would be nice to show a Tk dialog here saying we can't
    # import gtk...but then we would have to include all of the Tk libs in
    # with the win32 batteries-included installer
    try:
        import gtk
        import gobject
    except ImportError, e:
        print _('** Error: could not import gtk and/or gobject')
        print e
        if sys.platform == 'win32':
            print _('Please make sure that GTK_ROOT\\bin is in your PATH.')
        sys.exit(1)

    # create the user directory
    if not os.path.exists(paths.user_dir()):
        os.makedirs(paths.user_dir())

    # add console root handler, and file root handler, set it at the logging
    # level specified by BAUBLE_LOGGING, or at INFO level.
    filename = os.path.join(paths.user_dir(), 'bauble.log')
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fileHandler = logging.FileHandler(filename, 'w+')
    logging.getLogger().addHandler(fileHandler)
    consoleHandler = logging.StreamHandler()
    logging.getLogger().addHandler(consoleHandler)
    fileHandler.setFormatter(formatter)
    consoleHandler.setFormatter(formatter)
    fileHandler.setLevel(logging.DEBUG)
    consoleHandler.setLevel(consoleLevel)
Ejemplo n.º 23
0
    import pygtk
    if not main_is_frozen():
        pygtk.require("2.0")

    display = gtk.gdk.display_get_default()
    if display is None:
        print _("**Error: Bauble must be run in a windowed environment.")
        sys.exit(1)

    import bauble.pluginmgr as pluginmgr
    from bauble.prefs import prefs
    import bauble.utils as utils
    from bauble.utils.log import debug, warning, error

    # create the user directory
    if not os.path.exists(paths.user_dir()):
        os.makedirs(paths.user_dir())

    # initialize threading
    gobject.threads_init()

    try:
        import bauble.db as db
    except Exception, e:
        utils.message_dialog(utils.xml_safe_utf8(e), gtk.MESSAGE_ERROR)
        sys.exit(1)

    # declare module level variables
    global gui, default_icon, conn_name

    default_icon = os.path.join(paths.lib_dir(), "images", "icon.svg")
Ejemplo n.º 24
0
using a dictionary like interface. e.g. ::

    import bauble.prefs
    prefs.prefs[key] = value
"""

# TODO: maybe we should have a create method that creates the preferences
# todo a one time thing if the files doesn't exist

# TODO: Consider using ConfigObj since it does validation, type
# conversion and unicode automatically...the cons are that it adds
# another dependency and we would have to change the prefs interface
# throughout bauble

default_filename = 'config'
default_prefs_file = os.path.join(paths.user_dir(), default_filename)
"""
The default file for the preference settings file.
"""

config_version_pref = 'bauble.config.version'
"""
The preferences key for the bauble version of the preferences file.
"""

config_version = bauble.version_tuple[0], bauble.version_tuple[1]

date_format_pref = 'bauble.default_date_format'
"""
The preferences key for the default data format.
"""