Any good donothing?

Dialtone Dialtone.NOSPAM.ME at
Wed Apr 16 00:47:11 CEST 2003

Hi all. I'm working on a kind of all-in-one cd2mp3 encoder based on lame
and cdda2wav and pygame.

A little code snippet is the following (it is already indented once
because it is part of a bigger class, not so bigger, named cd2mp3).
My problem is to sync the 2 processes which are launched with the
os.system() call but without having the main program locked.
I initially thought that a wait inside a cicle would have got me an easy
solution but it didn't since it locks the main program anyway... Is
there any other way to make a do_nothing_for_some_time(n) function? Or
otherwise... is there another good way to sync those 2 processes without
having the main program locked (and also without having the encoder to
finish ecoding before the ripper has finished).  thanks a lot.

    def start(self, cdda=1, input_file=None, output_file=None, path="./library/audio/", bitrate=128):
#        mkdir_cmd = "mkdir %s%s" % (path, self.artist)
 #       os.system(mkdir_cmd)
  #      path = path + self.artist + "/"
        for i in xrange(self.start_track, self.num_tracks):
                self.infos = "Ripping: %s" % (self.tracks[i])
                self.infos2 = "Encoding: %s" % (self.tracks[i])
                self.infos = "Ripping track num %d" % (i)
                self.infos2 = "Encoding track num %d" % (i)
            self.surface.blit(self.text_bg, self.text_rect)
            self.rendered_text = pygame.font.Font(None, 20).render(self.infos, 1, [255, 255, 255])
            self.text_surf.blit(self.rendered_text, (0,0))
            # If tracks' names found
            if self.succeded:
                output_file = 1
            self.cdda2wav_string, self.wav2mp3_string = self.prefs(i, input_file, output_file, path, bitrate)
            if cdda:
                self.wav = os.system(self.cdda2wav_string)
                self.text_surf.blit(self.rendered_text, (0,0))
            self.surface.blit(self.text_bg, self.text_rect)
            self.rendered_text = pygame.font.Font(None, 20).render(self.infos2, 1, [255,255,255])
            self.text_surf.blit(self.rendered_text, (0,0))
            self.mp3 = os.system(self.wav2mp3_string)
            self.clean = os.system('rm -rf *.inf && rm -rf *.wav')
        text = "%d track(s) successfully encoded" % (self.num_tracks-self.start_track)
    def prefs(self, cur_track, input_file, output_file, path, bitrate=128, dev='/dev/cdrom'):
        settare le preferenze tipo 
        bitrate della conversione etc..
        if not output_file:
            output_file = "audio_%d.mp3" % (cur_track)
        else: output_file = "%s.mp3" % (self.__prepare(self.tracks[cur_track]))

        if not input_file:
            input_file = "audio.wav"
        cdda2wav_string = "cdda2wav -D %s -t %d+%d &" % (dev, cur_track, cur_track)
        wav2mp3_string = "lame -b %d %s %s%s &" % (bitrate, input_file, path, output_file)

        return cdda2wav_string, wav2mp3_string

    def lose_time(self, seconds):
        for i in xrange(seconds):

try: troll.uses(Brain)
except TypeError, data: 
Co-Responsabile Hardware Information & Technology

More information about the Python-list mailing list