
from subprocess import call
import sys
import json
import ConfigParser

def payload(text, conf):
	toPost = {
		"channel": "#" + conf.get("slack", "channel"),
		"username": conf.get("slack", "username"),
		"text": text,
		"icon_emoji": ":" + conf.get("slack", "icon_emoji") + ":"
	}
	return "payload=" + json.dumps(toPost)

def main():
	CONFIG_FILE = '/etc/slack_post.cfg'
	# read configuration 
	conf = ConfigParser.ConfigParser()
	conf.read(CONFIG_FILE)

	call([
		"curl",
		"-X",
		"POST",
		"--data-urlencode",
		payload(sys.argv[1], conf),
		conf.get("slack", "url")
		])

if __name__ == '__main__':
	main()

from subprocess import call
import sys
import json
import ConfigParser

def payload(text, conf):
	toPost = {
		"channel": "#" + conf.get("slack", "channel"),
		"username": conf.get("slack", "username"),
		"text": text,
		"icon_emoji": ":" + conf.get("slack", "icon_emoji") + ":"
	}
	return "payload=" + json.dumps(toPost)

def main():
	CONFIG_FILE = '/etc/brainy-beats.cfg'
	# read configuration 
	conf = ConfigParser.ConfigParser()
	conf.read(CONFIG_FILE)

	call([
		"curl",
		"-X",
		"POST",
		"--data-urlencode",
		payload(sys.argv[1], conf),
		conf.get("slack", "url")
		])

if __name__ == '__main__':
	main()
FIX - path of .cfg file corrected
FIX - path of .cfg file corrected

  
  from subprocess import call
  import sys
  import json
  import ConfigParser
  
  def payload(text, conf):
  	toPost = {
  		"channel": "#" + conf.get("slack", "channel"),
  		"username": conf.get("slack", "username"),
  		"text": text,
  		"icon_emoji": ":" + conf.get("slack", "icon_emoji") + ":"
  	}
  	return "payload=" + json.dumps(toPost)
  
  def main():
- 	CONFIG_FILE = '/etc/slack_post.cfg'
+ 	CONFIG_FILE = '/etc/brainy-beats.cfg'
  	# read configuration 
  	conf = ConfigParser.ConfigParser()
  	conf.read(CONFIG_FILE)
  
  	call([
  		"curl",
  		"-X",
  		"POST",
  		"--data-urlencode",
  		payload(sys.argv[1], conf),
  		conf.get("slack", "url")
  		])
  
  if __name__ == '__main__':
  	main()
FIX - path of .cfg file corrected
## Code Before:

from subprocess import call
import sys
import json
import ConfigParser

def payload(text, conf):
	toPost = {
		"channel": "#" + conf.get("slack", "channel"),
		"username": conf.get("slack", "username"),
		"text": text,
		"icon_emoji": ":" + conf.get("slack", "icon_emoji") + ":"
	}
	return "payload=" + json.dumps(toPost)

def main():
	CONFIG_FILE = '/etc/slack_post.cfg'
	# read configuration 
	conf = ConfigParser.ConfigParser()
	conf.read(CONFIG_FILE)

	call([
		"curl",
		"-X",
		"POST",
		"--data-urlencode",
		payload(sys.argv[1], conf),
		conf.get("slack", "url")
		])

if __name__ == '__main__':
	main()
## Instruction:
FIX - path of .cfg file corrected
## Code After:

from subprocess import call
import sys
import json
import ConfigParser

def payload(text, conf):
	toPost = {
		"channel": "#" + conf.get("slack", "channel"),
		"username": conf.get("slack", "username"),
		"text": text,
		"icon_emoji": ":" + conf.get("slack", "icon_emoji") + ":"
	}
	return "payload=" + json.dumps(toPost)

def main():
	CONFIG_FILE = '/etc/brainy-beats.cfg'
	# read configuration 
	conf = ConfigParser.ConfigParser()
	conf.read(CONFIG_FILE)

	call([
		"curl",
		"-X",
		"POST",
		"--data-urlencode",
		payload(sys.argv[1], conf),
		conf.get("slack", "url")
		])

if __name__ == '__main__':
	main()