Example #1
0
    def abort(self, failure=None):
        os.chdir(self.pwd)
        if not exists(self.project_name):
            return

        if failure:
            sh.bold_red_on_black("\r\nOOps, it broke :(\n\n{}\n".format(unicode(failure)))

        try:
            sh.bold_yellow_on_black("\r\nDo you want to remove the directory `{}` ?\n".format(self.project_name))
            if raw_input('(type "y" or "n"): ').lower().strip() == 'y':
                shutil.rmtree(self.project_name)

        except KeyboardInterrupt:
            sh.bold_red("Aborted without removing the directory `{}\n".format(self.project_name))
Example #2
0
    def create_file(self, name):
        context = self.get_context()

        with self.new_file(name) as destination:
            with self.skel_file(name) as view:
                sh.bold_white_on_black(u'Creating ')
                sh.bold_green_on_black(self.project_file(name))

                try:
                    body = view.read()
                    inside = body.format(**context)
                    destination.write(inside)
                except:
                    sh.bold_red(ballot)
                    raise
                else:
                    sh.bold_green(checkmark)
Example #3
0
    def prepare_for_heroku(self):
        if not self.should_create_heroku_app:
            return

        os.chdir(self.project_path)
        response = envoy.run('heroku version')
        if response and 'toolbelt' in response.std_out:
            sh.bold_red_on_black('Creating heroku app...\n')
            r = envoy.run("heroku create")

            if r.status_code is 0:
                sh.bold_green('\n{}\n'.format(r.std_out))
            else:
                sh.bold_red('\n{}\n{}'.format(r.std_out, r.std_err))

        else:
            sh.bold_red_on_black('Heroku toolbelt is not installed.\n')
            sh.bold_white_on_black('More info: http://toolbelt.heroku.com')