title: I got error : UnboundLocalError: local variable 'porc' referenced before assignment
body: <p>I am trying to execute this code</p>
  
  <p><strong>command3.py</strong></p>
  
  <pre><code>import microgear.client as microgear
  import os
  os.system("sudo pigpiod")
  import pigpio
  import RPi.GPIO as GPIO
  import subprocess
  
  
  
  piMASTER = pigpio.pi()
  
  
  ####################### NETPIE ####################    
  appid = 'xxxxxxxxx'
  gearkey = 'xxxxxxxxxx'
  gearsecret =  'xxxxxxxxxxxxxxxxxxxx'
  
  microgear.create(gearkey,gearsecret,appid,{'debugmode': True})
  
  
  
  
  def connection():
      print "Now I am connected with netpie"
  
  
  
  
  def subscription(topic,message):
          print topic+" "+message
          if message == "ON":
              proc = subprocess.Popen(["sudo", "python", "LED3.py"], shell = False)
          else:
              piMASTER.write(4, 0)
              proc.terminate()
  
  
  
  def disconnect():
       print "disconnect is work"
  
  microgear.setalias("switch")
  microgear.on_connect = connection
  microgear.on_message = subscription
  microgear.on_disconnect = disconnect
  microgear.subscribe("/mails")
  microgear.connect(True)
  </code></pre>
  
  <p><strong>LED3.py</strong></p>
  
  <pre><code>import time
  import pigpio
  import RPi.GPIO as GPIO
  
  pi= pigpio.pi()
  while True:
      pi.write(4, 1)          #Set LED pin 7 to HIGH
      time.sleep(1)           #Delay 1 second
      pi.write(4, 0)      #Set LED pin 7 to LOW
      time.sleep(1)
  </code></pre>
  
  <p>when message incoming 
  if message is "ON" LED3.py still work
  but if message is "OFF" I got this error</p>
  
  <pre><code>Traceback (most recent call last):
    File "command3.py", line 47, in &lt;module&gt;
      microgear.connect(True)
    File "/usr/local/lib/python2.7/dist-packages/microgear/client.py", line 143, in connect
      microgear.mqtt_client.loop_forever()
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1378, in loop_forever
      rc = self.loop(timeout, max_packets)
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 897, in loop
      rc = self.loop_read(max_packets)
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1177, in loop_read
      rc = self._packet_read()
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1766, in _packet_read
      rc = self._packet_handle()
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2239, in _packet_handle
      return self._handle_publish()
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2414, in _handle_publish
      self._handle_on_message(message)
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2574, in _handle_on_message
      self.on_message(self, self._userdata, message)
    File "/usr/local/lib/python2.7/dist-packages/microgear/client.py", line 105, in client_on_message
      on_message(msg.topic,str(msg.payload))
    File "command3.py", line 35, in subscription
      proc.terminate()
  UnboundLocalError: local variable 'proc' referenced before assignment
  </code></pre>
  
  <p>*Sorry if I'm not good in english.And I'm just start to learn about python.</p>