
from flask.ext.script import Manager, prompt, prompt_bool, prompt_pass
from db_create import (
    init_db,
    drop_db,
    init_admin_user,
    init_entry,
    init_category,
    init_tag
)
from flask.ext.migrate import MigrateCommand
from logpot.app import app
import os

if os.path.exists('.env'):
    print('Importing environment from .env...')
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

manager = Manager(app)
manager.add_command('db', MigrateCommand)


@manager.command
def run():
    app.run(threaded=True)


@manager.command
def initialize():
    if prompt_bool("Are you sure you want to create DB and initialize?"):
        drop_db()
        init_db()
        if init_admin():
            init_category()
            init_tag()
            init_entry()
            print('Success!')

@manager.command
def init_admin():
    name = prompt('Resister admin user.\n[?] input username: ')
    email = prompt('[?] input email: ')
    password = prompt_pass('[?] input password: ')
    confirm_password = prompt_pass('[?] input password again: ')

    if not password == confirm_password:
        print('Password does not match.')
        return False
    else:
        init_admin_user(name, email, password)
        return True


if __name__ == "__main__":
    manager.run()


import os
if os.path.exists('.env'):
    print('Importing environment from .env...')
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

from flask.ext.script import Manager, prompt, prompt_bool, prompt_pass
from db_create import (
    init_db,
    drop_db,
    init_admin_user,
    init_entry,
    init_category,
    init_tag
)
from flask.ext.migrate import MigrateCommand
from logpot.app import app

manager = Manager(app)
manager.add_command('db', MigrateCommand)


@manager.command
def run():
    app.run(threaded=True)


@manager.command
def initialize():
    if prompt_bool("Are you sure you want to create DB and initialize?"):
        drop_db()
        init_db()
        if init_admin():
            init_category()
            init_tag()
            init_entry()
            print('Success!')

@manager.command
def init_admin():
    name = prompt('Resister admin user.\n[?] input username: ')
    email = prompt('[?] input email: ')
    password = prompt_pass('[?] input password: ')
    confirm_password = prompt_pass('[?] input password again: ')

    if not password == confirm_password:
        print('Password does not match.')
        return False
    else:
        init_admin_user(name, email, password)
        return True


if __name__ == "__main__":
    manager.run()

Fix import location of environment variables
Fix import location of environment variables

+ 
+ import os
+ if os.path.exists('.env'):
+     print('Importing environment from .env...')
+     for line in open('.env'):
+         var = line.strip().split('=')
+         if len(var) == 2:
+             os.environ[var[0]] = var[1]
  
  from flask.ext.script import Manager, prompt, prompt_bool, prompt_pass
  from db_create import (
      init_db,
      drop_db,
      init_admin_user,
      init_entry,
      init_category,
      init_tag
  )
  from flask.ext.migrate import MigrateCommand
  from logpot.app import app
- import os
- 
- if os.path.exists('.env'):
-     print('Importing environment from .env...')
-     for line in open('.env'):
-         var = line.strip().split('=')
-         if len(var) == 2:
-             os.environ[var[0]] = var[1]
  
  manager = Manager(app)
  manager.add_command('db', MigrateCommand)
  
  
  @manager.command
  def run():
      app.run(threaded=True)
  
  
  @manager.command
  def initialize():
      if prompt_bool("Are you sure you want to create DB and initialize?"):
          drop_db()
          init_db()
          if init_admin():
              init_category()
              init_tag()
              init_entry()
              print('Success!')
  
  @manager.command
  def init_admin():
      name = prompt('Resister admin user.\n[?] input username: ')
      email = prompt('[?] input email: ')
      password = prompt_pass('[?] input password: ')
      confirm_password = prompt_pass('[?] input password again: ')
  
      if not password == confirm_password:
          print('Password does not match.')
          return False
      else:
          init_admin_user(name, email, password)
          return True
  
  
  if __name__ == "__main__":
      manager.run()
  
Fix import location of environment variables
## Code Before:

from flask.ext.script import Manager, prompt, prompt_bool, prompt_pass
from db_create import (
    init_db,
    drop_db,
    init_admin_user,
    init_entry,
    init_category,
    init_tag
)
from flask.ext.migrate import MigrateCommand
from logpot.app import app
import os

if os.path.exists('.env'):
    print('Importing environment from .env...')
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

manager = Manager(app)
manager.add_command('db', MigrateCommand)


@manager.command
def run():
    app.run(threaded=True)


@manager.command
def initialize():
    if prompt_bool("Are you sure you want to create DB and initialize?"):
        drop_db()
        init_db()
        if init_admin():
            init_category()
            init_tag()
            init_entry()
            print('Success!')

@manager.command
def init_admin():
    name = prompt('Resister admin user.\n[?] input username: ')
    email = prompt('[?] input email: ')
    password = prompt_pass('[?] input password: ')
    confirm_password = prompt_pass('[?] input password again: ')

    if not password == confirm_password:
        print('Password does not match.')
        return False
    else:
        init_admin_user(name, email, password)
        return True


if __name__ == "__main__":
    manager.run()

## Instruction:
Fix import location of environment variables
## Code After:

import os
if os.path.exists('.env'):
    print('Importing environment from .env...')
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

from flask.ext.script import Manager, prompt, prompt_bool, prompt_pass
from db_create import (
    init_db,
    drop_db,
    init_admin_user,
    init_entry,
    init_category,
    init_tag
)
from flask.ext.migrate import MigrateCommand
from logpot.app import app

manager = Manager(app)
manager.add_command('db', MigrateCommand)


@manager.command
def run():
    app.run(threaded=True)


@manager.command
def initialize():
    if prompt_bool("Are you sure you want to create DB and initialize?"):
        drop_db()
        init_db()
        if init_admin():
            init_category()
            init_tag()
            init_entry()
            print('Success!')

@manager.command
def init_admin():
    name = prompt('Resister admin user.\n[?] input username: ')
    email = prompt('[?] input email: ')
    password = prompt_pass('[?] input password: ')
    confirm_password = prompt_pass('[?] input password again: ')

    if not password == confirm_password:
        print('Password does not match.')
        return False
    else:
        init_admin_user(name, email, password)
        return True


if __name__ == "__main__":
    manager.run()
