Changeset 287 for trunk


Ignore:
Timestamp:
07/29/09 05:30:49 (3 years ago)
Author:
marc
Message:

Better placement of files in APPDATA Win 7/XP. Basic audio support on win and linux. better os detection

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.py

    r284 r287  
    2727 
    2828import os 
     29import platform 
    2930import sys 
    3031import ConfigParser 
     
    4849config_instance = ConfigParser.ConfigParser() 
    4950image_dir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'share/images/') 
     51sound_dir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'share/sounds/') 
    5052system = os.name 
     53# We need something more specific  
     54platform = platform.system() 
     55 
    5156#: Minimum screen height to display all panes of Itaka 
    5257min_screen_height = 800 
     
    7580configuration_values = {} 
    7681 
    77 if os.environ.get('HOME'): 
    78     save_path = os.path.join(os.environ.get('HOME'), '.itaka') 
     82# Second best choice, TMP/TEMP on most systems 
     83save_path = os.environ.get('TMP') or os.environ.get('TEMP') 
     84 
     85# Try APPDATA on Windows or $HOME on POSIX 
     86if (system == 'nt'): 
     87    if os.environ.get('APPDATA'): 
     88                save_path = os.path.join(os.environ.get('APPDATA'), 'itaka') 
     89    elif os.environ.get('HOME'): 
     90                save_path = os.path.join(os.environ.get('HOME'), 'itaka') 
    7991else: 
    80     save_path = os.environ.get('TMP') or os.environ.get('TEMP') 
    81  
     92    if os.environ.get('HOME'): 
     93        save_path = os.path.join(os.environ.get('HOME'), '.itaka') 
     94 
     95print save_path 
    8296#: Default HTML headers and footers for the server. 
    8397# Putting <meta http-equiv="Refresh" content="5; url=/"> is very useful for debugging 
     
    163177                self.config_file = os.path.join(os.environ['HOME'], '.itaka/itaka.conf') 
    164178        elif (system == 'nt'): 
    165             if not (os.path.exists(os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini'))): 
    166                 self.create(os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini')) 
     179            if not (os.path.exists(os.path.join(os.environ['APPDATA'], 'Itaka/config.ini'))): 
     180                self.create(os.path.join(os.environ['APPDATA'], 'Itaka/config.ini')) 
    167181            else: 
    168                 self.config_file = os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini') 
     182                self.config_file = os.path.join(os.environ['APPDATA'], 'Itaka/config.ini') 
    169183        else: 
    170184            # Generic path 
  • trunk/server.py

    r280 r287  
    488488            n.attach_to_status_icon(self.gui.status_icon) 
    489489            n.show() 
     490        # if self.configuration['server']['notifysound'] 
     491        if self.itaka_globals.platform == 'Windows': 
     492            import winsound 
     493            # ASYNC lets the program continue and does not wait for end of play. 
     494            winsound.PlaySound(os.path.join(self.itaka_globals.sound_dir, "snap.wav"), winsound.SND_FILENAME|winsound.SND_ASYNC) 
     495        elif self.itaka_globals.platform == 'Linux': 
     496               from wave import open as waveOpen 
     497               from ossaudiodev import open as ossOpen 
     498               s = waveOpen(os.path.join(self.itaka_globals.sound_dir, "snap.wav"),'rb') 
     499               (nc,sw,fr,nf,comptype, compname) = s.getparams( ) 
     500               dsp = ossOpen('/dev/dsp','w') 
     501               try: 
     502                 from ossaudiodev import AFMT_S16_NE 
     503               except ImportError: 
     504                 if byteorder == "little": 
     505                   AFMT_S16_NE = ossaudiodev.AFMT_S16_LE 
     506                 else: 
     507                   AFMT_S16_NE = ossaudiodev.AFMT_S16_BE 
     508               dsp.setparameters(AFMT_S16_NE, nc, fr) 
     509               data = s.readframes(nf) 
     510               s.close() 
     511               dsp.write(data) 
     512               dsp.close() 
     513 
     514         
    490515        self.gui.update_gui(self.counter, self.ip, self.time) 
    491516 
  • trunk/uigtk.py

    r285 r287  
    550550         
    551551        # Create our Hboxes 
    552         for n in xrange(1, 11+1): 
     552        for n in xrange(1, 12+1): 
    553553            setattr(self, 'hbox_preferences_%d' % (n), gtk.HBox(False, 0)) 
    554554 
     
    593593 
    594594        if self.itaka_globals.notify_available:  
    595             self.label_preferences_notifications = gtk.Label(_('Notifications')) 
     595            self.label_preferences_notifications = gtk.Label(_('Desktop notifications')) 
    596596            self.label_preferences_notifications.set_justify(gtk.JUSTIFY_LEFT) 
    597597            self.label_preferences_notifications.set_alignment(0, 0.50) 
     598             
     599        self.label_preferences_notifications_sound = gtk.Label(_('Audio notifications')) 
     600        self.label_preferences_notifications_sound.set_justify(gtk.JUSTIFY_LEFT) 
     601        self.label_preferences_notifications_sound.set_alignment(0, 0.50) 
    598602 
    599603        self.label_preferences_timestamp = gtk.Label(_('Show timestamp in log')) 
     
    659663 
    660664        self.check_preferences_timestamp = gtk.CheckButton() 
     665##        if self.configuration['log']['timestamp']: 
     666##            self.check_preferences_notifications.set_active(1) 
     667##        else:  
     668##            self.check_preferences_notifications.set_active(0) 
     669 
     670        self.check_preferences_notifications_sound = gtk.CheckButton() 
    661671##        if self.configuration['log']['timestamp']: 
    662672##            self.check_preferences_notifications.set_active(1) 
     
    703713            self.hbox_preferences_9.pack_end(self.check_preferences_notifications, False, False, 7) 
    704714 
    705         self.hbox_preferences_10.pack_start(self.label_preferences_timestamp, False, False, 12) 
    706         self.hbox_preferences_10.pack_end(self.check_preferences_timestamp, False, False, 7) 
    707  
    708         self.hbox_preferences_11.pack_start(self.button_preferences_about, False, False, 7) 
    709         self.hbox_preferences_11.pack_end(self.button_preferences_close, False, False, 7) 
     715        self.hbox_preferences_10.pack_start(self.label_preferences_notifications_sound, False, False, 12) 
     716        self.hbox_preferences_10.pack_end(self.check_preferences_notifications_sound, False, False, 7) 
     717 
     718        self.hbox_preferences_11.pack_start(self.label_preferences_timestamp, False, False, 12) 
     719        self.hbox_preferences_11.pack_end(self.check_preferences_timestamp, False, False, 7) 
     720 
     721        self.hbox_preferences_12.pack_start(self.button_preferences_about, False, False, 7) 
     722        self.hbox_preferences_12.pack_end(self.button_preferences_close, False, False, 7) 
    710723 
    711724        self.vbox_preferences_items.pack_start(self.hbox_preferences_1, False, False, 0) 
     
    725738 
    726739        self.vbox_preferences_items.pack_start(self.hbox_preferences_10, False, False, 0) 
     740        self.vbox_preferences_items.pack_start(self.hbox_preferences_11, False, False, 0) 
    727741 
    728742        self.frame_preference_settings.add(self.vbox_preferences_items) 
    729743        self.vbox_preferences.pack_start(self.frame_preference_settings, False, False, 0) 
    730         self.vbox_preferences.pack_start(self.hbox_preferences_11, False, False, 4) 
     744        self.vbox_preferences.pack_start(self.hbox_preferences_12, False, False, 4) 
    731745 
    732746        self.window.add(self.vbox) 
Note: See TracChangeset for help on using the changeset viewer.