def presetup(app_defaults_filename, system_filename, user_filename): if not os.path.exists(filesystem.app_data()): os.makedirs(filesystem.app_data()) if not os.path.exists(filesystem.user_data()): os.makedirs(filesystem.user_data()) try: cfg.initialise(app_defaults_filename, system_filename, user_filename) except UnicodeDecodeError: traceback.print_exc() print(file=sys.stderr) print("\n".join( textwrap.wrap( "Your %s file is not properly utf8 encoded. Most likely" " it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))), file=sys.stderr) print(file=sys.stderr) sys.exit("I give up (solfege.py)") except cfg.CfgParseException as e: i18n.setup(".") a, b = os.path.split(user_filename) renamed_fn = os.path.join(a, "BAD-" + b) m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, _("Parsing %s failed") % filesystem.rcfile()) m.format_secondary_text( str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn)) m.add_buttons("Rename", 10) m.add_buttons(Gtk.STOCK_QUIT, 11) m.set_default_response(11) ret = m.run() if ret == 10: os.rename(user_filename, renamed_fn) m.destroy() cfg.initialise(app_defaults_filename, system_filename, user_filename) else: sys.exit(1) # MIGRATION from 2.9.2 to 2.9.3 if cfg.get_string("app/lc_messages") == 'C (english)': cfg.set_string("app/lc_messages", "C")
def presetup(app_defaults_filename, system_filename, user_filename): if not os.path.exists(filesystem.app_data()): os.makedirs(filesystem.app_data()) if not os.path.exists(filesystem.user_data()): os.makedirs(filesystem.user_data()) try: cfg.initialise(app_defaults_filename, system_filename, user_filename) except UnicodeDecodeError, e: traceback.print_exc() print >> sys.stderr print >> sys.stderr, "\n".join(textwrap.wrap( "Your %s file is not properly utf8 encoded. Most likely" " it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))) print >> sys.stderr sys.exit("I give up (solfege.py)")
def presetup(app_defaults_filename, system_filename, user_filename): if not os.path.exists(filesystem.app_data()): os.makedirs(filesystem.app_data()) if not os.path.exists(filesystem.user_data()): os.makedirs(filesystem.user_data()) try: cfg.initialise(app_defaults_filename, system_filename, user_filename) except UnicodeDecodeError, e: traceback.print_exc() print >> sys.stderr print >> sys.stderr, "\n".join( textwrap.wrap( "Your %s file is not properly utf8 encoded. Most likely" " it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))) print >> sys.stderr sys.exit("I give up (solfege.py)")
def presetup(app_defaults_filename, system_filename, user_filename): if not os.path.exists(filesystem.app_data()): os.makedirs(filesystem.app_data()) if not os.path.exists(filesystem.user_data()): os.makedirs(filesystem.user_data()) try: cfg.initialise(app_defaults_filename, system_filename, user_filename) except UnicodeDecodeError: traceback.print_exc() print(file=sys.stderr) print("\n".join(textwrap.wrap( "Your %s file is not properly utf8 encoded. Most likely" " it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))), file=sys.stderr) print(file=sys.stderr) sys.exit("I give up (solfege.py)") except cfg.CfgParseException as e: i18n.setup(".") a, b = os.path.split(user_filename) renamed_fn = os.path.join(a, "BAD-" + b) m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, _("Parsing %s failed") % filesystem.rcfile()) m.format_secondary_text(str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn)) m.add_buttons("Rename", 10) m.add_buttons(Gtk.STOCK_QUIT, 11) m.set_default_response(11) ret = m.run() if ret == 10: os.rename(user_filename, renamed_fn) m.destroy() cfg.initialise(app_defaults_filename, system_filename, user_filename) else: sys.exit(1) # MIGRATION from 2.9.2 to 2.9.3 if cfg.get_string("app/lc_messages") == 'C (english)': cfg.set_string("app/lc_messages", "C")
else: os.mkdir(filesystem.app_data()) if not os.path.exists(filesystem.rcfile()): if os.path.exists(os.path.join(filesystem.get_home_dir(), ".solfegerc")): shutil.copy(os.path.join(filesystem.get_home_dir(), ".solfegerc"), filesystem.rcfile()) except (IOError, os.error), e: print "Migration failed:", e if not os.path.exists(filesystem.app_data()): os.makedirs(filesystem.app_data()) if not os.path.exists(filesystem.user_data()): os.makedirs(filesystem.user_data()) try: cfg.initialise("default.config", None, filesystem.rcfile()) except UnicodeDecodeError, e: traceback.print_exc() print >> sys.stderr print >> sys.stderr, "\n".join(textwrap.wrap( "Your %s file is not properly utf8 encoded. Most likely" " it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))) print >> sys.stderr sys.exit("I give up (solfege.py)") # i18n should be imported very early in program init because it setup # the _ and _i functions for the whole program. import solfege.i18n
sys.__displayhook__ = f from solfege import testlib import solfege.i18n solfege.i18n.setup(".") from solfege import lessonfile lessonfile.infocache = lessonfile.InfoCache() import solfege.statistics solfege.db = solfege.statistics.DB(None) import tempfile lessonfile.MusicBaseClass.temp_dir = tempfile.mkdtemp(prefix="solfege-") from solfege import cfg cfg.initialise("default.config", None, "") cfg.set_int('config/preferred_instrument', 0) cfg.set_int('config/lowest_instrument', 1) cfg.set_int('config/middle_instrument', 2) cfg.set_int('config/highest_instrument', 3) cfg.set_int('config/lowest_instrument_volume', 121) cfg.set_int('config/middle_instrument_volume', 122) cfg.set_int('config/highest_instrument_volume', 123) cfg.set_bool('config/override_default_instrument', False) cfg.set_bool('testing/may_play_sound', False) if os.path.exists(testlib.outdir): shutil.rmtree(testlib.outdir) os.mkdir(testlib.outdir) from solfege import soundcard
#!/usr/bin/python import sys sys.path.insert(0, ".") from solfege import i18n i18n.setup(".", "C") from solfege import cfg from solfege import filesystem cfg.initialise("default.config", None, filesystem.rcfile()) from solfege import soundcard from solfege.mpd import Track # This works nice with ALSA and OSS emulation with SB Live card: soundcard.initialise_external_midiplayer() #soundcard.initialise_devicefile("/dev/sequencer2", 2) print """ You should here three major triads: G G G E E E_E C C C_C_C C (piano) (flute) (strings ens) Press enter when the sounds are finished. """ t = Track() t.set_bpm(120, 4)
" characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))) print >> sys.stderr sys.exit("I give up (solfege.py)") except cfg.CfgParseException, e: i18n.setup(".") a, b = os.path.split(user_filename) renamed_fn = os.path.join(a, "BAD-" + b) m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, _("Parsing %s failed") % filesystem.rcfile()) m.format_secondary_text( str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn)) m.add_buttons("Rename", 10) m.add_buttons(Gtk.STOCK_QUIT, 11) m.set_default_response(11) ret = m.run() if ret == 10: os.rename(user_filename, renamed_fn) m.destroy() cfg.initialise(app_defaults_filename, system_filename, user_filename) else: sys.exit(1) # MIGRATION from 2.9.2 to 2.9.3 if cfg.get_string("app/lc_messages") == 'C (english)': cfg.set_string("app/lc_messages", "C")
" it is the path to some external program that contain non-ascii" " characters. Please edit or delete the file. Or email it to" " [email protected], and he will tell you what the problem is." % filesystem.rcfile().encode("ascii", "backslashreplace"))) print >> sys.stderr sys.exit("I give up (solfege.py)") except cfg.CfgParseException, e: i18n.setup(".") a, b = os.path.split(user_filename) renamed_fn = os.path.join(a, "BAD-"+b) m = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, _("Parsing %s failed") % filesystem.rcfile()) m.format_secondary_text(str(e) + "\n\n" + _("We cannot recover from this, we can rename the corrupt file to %s and then start the program." % renamed_fn)) m.add_buttons("Rename", 10) m.add_buttons(Gtk.STOCK_QUIT, 11) m.set_default_response(11) ret = m.run() if ret == 10: os.rename(user_filename, renamed_fn) m.destroy() cfg.initialise(app_defaults_filename, system_filename, user_filename) else: sys.exit(1) # MIGRATION from 2.9.2 to 2.9.3 if cfg.get_string("app/lc_messages") == 'C (english)': cfg.set_string("app/lc_messages", "C")