def store_in_bbdd(info, debug=False): """ Store in BBDD information. :param info: information to store in BBDD :type info: dict({ 'PLUGIN_FAMILY' : list([PLUGIN_ID, PLUGIN_FILE_NAME])}) :return: True if all done Oks. False otherwise. :rtype: bool """ from models import Families, Plugin try: for k, v in info.iteritems(): f = Families() f.family_name = k f.save() for plugin in v: l_plugin_id = plugin[0] l_path = os.path.split(plugin[1])[1] p = Plugin() p.plugin_id = l_plugin_id p.plugin_file_name = l_path p.family = f p.save() except Exception,e: if debug: print "Error generation BBDD: %s" % str(e) return False
log_file.writelines(l) # To screen print '\n'.join(l) return # Debug message if debug: print "Processing: %s (Family) | %s (script_id)" % (m_plugin_family, m_plugin_id) from models import Families, Plugin f = Families() f.family_name = m_plugin_family f.save() p = Plugin() p.plugin_id = m_plugin_id p.plugin_file_name = f_name p.family = f p.save() #try: #results[m_plugin_family].append([m_plugin_id, f_name]) #except KeyError: #results[m_plugin_family] = d.list() #results[m_plugin_family].append([m_plugin_id, f_name]) #return {m_plugin_family : [m_plugin_id, f_name]}