예제 #1
0
    def delete(self, name, project=None, delete_all=False):
        profile = Profile(name, project=project)

        if not profile.exists():
            self.red(texts.ERROR_PROFILE_DOESNT_EXIST.format(name))
            return

        profile.delete()
        delete_text = texts.LOG_DELETE_PROFILE.format(name)
        if delete_all:
            self.pgreen(delete_text)
        else:
            self.green(delete_text)

        return True
예제 #2
0
    def run(self, **options):
        name = slugify(options.get('profile'))
        project = options.get('project')

        if not name:
            self.red(texts.ERROR_PROFILE_INVALID_NAME.format(
                options.get('profile')
            ))
            return

        profile = Profile(name, project=project)

        if not profile.exists():
            self.red(texts.ERROR_PROFILE_DOESNT_EXIST.format(name))
            return

        profile.activate()
        self.green(texts.LOG_PROFILE_ACTIVATED.format(name))
예제 #3
0
    def check_active(self):
        name = self.settings.get('active')
        project = None

        if not name or not slugify(name):
            self.red(texts.ERROR_NO_ACTIVE_PROFILE)
            return

        if ':' in name:
            name, project = name.split(':')

        profile = Profile(name, project=project)
        if not profile.exists():
            self.settings.update({
                'active': None
            }).save()
            self.red(texts.ERROR_NO_ACTIVE_PROFILE)
            return
        return profile
예제 #4
0
    def run(self, **options):
        ipython_options = list(options.get('ipython_options', []))
        project = options.get('project')
        name = options.get('profile')

        if not (name and slugify(name)):
            active = self.settings.get('active')
            profiles_list = self.list_profiles(
                self.settings.get('path'), show_project=True)

            if active and active in profiles_list:
                if ':' in active:
                    active_name, active_project = active.split(':')
                    profile = Profile(active_name, project=active_project)
                else:
                    profile = Profile(active, project=project)
            else:
                profile = None
        else:
            profile = Profile(name, project=project)

        if not profile:
            IPython.start_ipython(argv=ipython_options)
            return

        if not profile.exists():
            self.red(texts.ERROR_PROFILE_DOESNT_EXIST_RUN.format(profile.name))
            return

        self.settings.update({
            'last': profile.name
        }).save()

        profile.shell(ipython_options)
예제 #5
0
    def run(self, **options):
        name = slugify(options.get('profile'))
        project = options.get('project')
        no_ignore = options.get('no_ignore')

        if not name:
            self.red(texts.ERROR_PROFILE_INVALID_NAME.format(
                options.get('profile')
            ))
            return

        profile = Profile(name, project=project, ignore_project=no_ignore)

        if profile.exists():
            self.red(texts.ERROR_PROFILE_EXISTS.format(name))
            return

        all_profiles = self.list_profiles(self.settings.get('path'))
        profile.create()
        self.green(texts.LOG_NEW_PROFILE.format(name))

        if options.get('active') or not all_profiles:
            profile.activate()
            self.green(texts.LOG_PROFILE_ACTIVATED.format(name))