 
   show: ->
     # Get out of here unless this is a python file
-    return unless @getGrammar() == 'Python'
+    editor = atom.workspace.getActiveTextEditor()
+    return unless editor?
+    return unless editor.getGrammar().name == 'Python'
 
     @panel ?= atom.workspace.addModalPanel(item: this)
     @panel.show()


module.exports =
class SimpleFlake8View extends SelectListView

  configDefaults:
    flake8Command: "flake8"
    ignoreErrors: ""
    mcCabeComplexityThreshold: ""
    validateOnSave: true
  keyBindings: null

  @activate: ->
    view = new SimpleFlake8View

  params = ["--show-source", filePath]
  ignoreErrors = atom.config.get "simple-flake8.ignoreErrors"
  mcCabeComplexityThreshold = atom.config.get "simple-flake8.mcCabeComplexityThreshold"
  flake8cmd = atom.config.get("simple-flake8.flake8Command", "flake8")
  console.log(flake8cmd)
  if ignoreErrors
    params.push("--ignore=#{ ignoreErrors }")

  if mcCabeComplexityThreshold
    params.push("--max-complexity=#{ mcCabeComplexityThreshold }")

  proc = process.spawn flake8cmd, params
