~therp-nl/anybox.recipe.openerp/jbaudoux-relative_paths_resolve_conflict

« back to all changes in this revision

Viewing changes to anybox/recipe/openerp/server.py

  • Committer: Jacques-Etienne Baudoux
  • Date: 2013-09-08 13:52:41 UTC
  • Revision ID: je@bcim.be-20130908135241-ln1r3mue2ajt076j
pep8

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
            desc = self.openerp_scripts[name] = dict(entry=entry)
282
282
            return name, desc
283
283
 
284
 
    def _relativitize(self,path):
 
284
    def _relativitize(self, path):
285
285
        """Inspired from easy_install"""
286
286
        if self._relative_paths:
287
 
            eggs = os.path.normcase(os.path.abspath(self.b_options['eggs-directory']))
 
287
            eggs = os.path.normcase(os.path.abspath(
 
288
                self.b_options['eggs-directory']))
288
289
            common = os.path.dirname(os.path.commonprefix([path, eggs]))
289
290
            if (common == self._relative_paths or
290
291
                common.startswith(os.path.join(self._relative_paths, ''))
298
299
        desc = self._get_or_create_script('openerp_starter',
299
300
                                          name=qualified_name)[1]
300
301
        desc.update(
301
 
            arguments='%r, %r, version=%r' % (self._relativitize(self._get_server_command()),
302
 
                                              self._relativitize(self.config_path),
303
 
                                              self.major_version),
 
302
            arguments='%r, %r, version=%r' % (
 
303
                self._relativitize(self._get_server_command()),
 
304
                self._relativitize(self.config_path),
 
305
                self.major_version),
304
306
        )
305
307
 
306
308
        startup_delay = float(self.options.get('startup_delay', 0))
366
368
        # to resort on hacking sys.argv
367
369
        desc['initialization'] = (
368
370
            "from sys import argv; argv[1:] = ['%s', '-c', '%s.conf.py']" % (
369
 
                gunicorn_entry_point, self._relativitize(join(self.etc, qualified_name))))
 
371
                gunicorn_entry_point,
 
372
                self._relativitize(join(self.etc, qualified_name))))
370
373
 
371
374
    def _register_openerp_command(self, qualified_name):
372
375
        """Register https://launchpad.net/openerp-command for install.
429
432
        desc = self._get_or_create_script('openerp_cron_worker',
430
433
                                          name=qualified_name)[1]
431
434
        desc.update(entry='openerp_cron_worker',
432
 
                    arguments='%s, %s' % (self._relativitize(script_src),
433
 
                                          self._relativitize(self.config_path)),
 
435
                    arguments='%s, %s' % (
 
436
                        self._relativitize(script_src),
 
437
                        self._relativitize(self.config_path)),
434
438
                    initialization='',
435
439
                    )
436
440