~osomon/moovida/pipestuff-youtube

« back to all changes in this revision

Viewing changes to cmdline.py

  • Committer: Ugo Riboni
  • Date: 2010-02-01 10:09:17 UTC
  • Revision ID: uriboni@fluendo.com-20100201100917-w3l9t1kn3q5i3hbh
More python 2.5 fixes and some cmd line handling fixes as well

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
 
136
136
    @defer.inlineCallbacks
137
137
    def run(self):
138
 
        self.log.info("Action %s on %s.%s" % (self.conf['action'],
139
 
                                              self.conf['service'],
140
 
                                              self.conf['method']))
 
138
        # This check is necessary because MyOptions.parseArgs will not be called
 
139
        # if there are no extra arguments on the cmd line.
 
140
        if self.conf.get('provider') is None or \
 
141
           self.conf.get('service') is None or \
 
142
           self.conf.get('method') is None:
 
143
                print '%s: You need to specify what service you want to call.' \
 
144
                      '%s: Try --help for usage details.' % \
 
145
                      (sys.argv[0], sys.argv[0])
 
146
                return
 
147
        
 
148
        self.log.info("Action %s on %s.%s.%s" % (self.conf['action'],
 
149
                                                 self.conf['provider'],
 
150
                                                 self.conf['service'],
 
151
                                                 self.conf['method']))
141
152
        self.log.info("Arguments: %s" % (self.conf['args']))
142
153
 
143
154
        self._retriever.register_providers()
165
176
                               % (service_name, provider_name))
166
177
                return
167
178
 
168
 
            method_name = self.conf['method']
169
 
            pl = service.methods.get(method_name)
170
 
            if method is None:
 
179
            method_name = self.conf.get('method')
 
180
            if method_name is None:
171
181
                self.log.error("Method %s is not defined for service %s.%s" \
172
182
                               % (method_name, provider_name, service_name))
173
183
                return
174
184
            
 
185
            method = service.methods.get(method_name)
175
186
            pipeline = method.pipeline
176
187
            if action == 'dot':
177
188
                dot = pipeline.to_dot()
183
194
                        f = open(dotfile, 'w')
184
195
                        f.write(dot)
185
196
                        f.close()
186
 
                    except Exception as e:
187
 
                        self.log.exception("Error accessing output file %s" % dotfile)
 
197
                    except Exception, e:
 
198
                        self.log.exception("Error accessing output file %s: %s"\
 
199
                                           % (dotfile, e))
188
200
                else:
189
201
                    print dot
190
202
            else: