Revision 2567ca37 py/scenic/preview.py

b/py/scenic/preview.py
6 6
from scenic import sig
7 7
from scenic import process
8 8
from scenic.internationalization import _
9
from scenic import logger
10

  
11
log = logger.start(name="preview")
9 12

  
10 13
class Preview(object):
11 14
    """
......
39 42
        x_window_id = None
40 43
        if not self.app.config.preview_in_window:
41 44
            if self.app.gui.preview_area_x_window_id is None:
42
                print("WARNING: XID of the preview drawing area is None !")
45
                log.error("XID of the preview drawing area is None !")
43 46
            else:
44 47
                x_window_id = self.app.gui.preview_area_x_window_id
45 48
        command = "milhouse --videosource %s --localvideo --window-title \"%s\" --width %s --height %s --aspect-ratio %s" % (self.app.config.video_source, window_title, width, height, aspect_ratio, )
......
54 57
        if self.app.config.video_source != "videotestsrc":
55 58
            dev = self.app.parse_v4l2_device_name(self.app.config.video_device)
56 59
            if dev is None:
57
                print "v4l2 device is not found !", self.app.config.video_device
60
                log.error("v4l2 device is not found ! %s" % (self.app.config.video_device))
58 61
                #FIXME: handle this
59 62
            video_device = dev["name"]
60 63
            command += " --videodevice %s" % (video_device)
61 64
        return command
62 65
        
63 66
    def start(self):
64
        print("Starting the preview")
67
        log.info("Starting the preview")
65 68
        if self.state != process.STATE_STOPPED:
66 69
            raise RuntimeError("Cannot start preview since it is %s." % (self.state)) # the programmer has done something wrong if we're here.
67 70
        else:
......
74 77
        self.process_manager.start()
75 78

  
76 79
    def on_stdout_line(self, process_manager, line):
77
        print line
80
        log.debug(line)
78 81

  
79 82
    def on_stderr_line(self, process_manager, line):
80
        print line        
83
        log.debug(line)
81 84
        
82 85
    def on_process_state_changed(self, process_manager, process_state):
83 86
        """
84 87
        Slot for the ProcessManager.state_changed_signal
85 88
        """
86
        print "Preview:", process_manager, process_state
89
        log.debug("Preview: %s %s" % (process_manager, process_state))
87 90
        if process_state == process.STATE_RUNNING:
88 91
            # As soon as it is running, set our state to running
89 92
            if self.state == process.STATE_STARTING:
......
109 112
        """
110 113
        Stops the preview process.
111 114
        """
112
        print("Stopping the preview")
115
        log.info("Stopping the preview")
113 116
        if self.state in [process.STATE_RUNNING, process.STATE_STARTING]:
114 117
            self._set_state(process.STATE_STOPPING)
115 118
            if self.process_manager is not None:
116 119
                if self.process_manager.state != process.STATE_STOPPED and self.process_manager.state != process.STATE_STOPPING:
117
                    print('stopping the preview process')
118 120
                    self.process_manager.stop()
119 121
        else:
120
            print("Warning: preview state is %s" % (self.state))
122
            log.debug("Warning: preview state is %s" % (self.state))
121 123
    

Also available in: Unified diff