Ejemplo n.º 1
0
 def __init__(self):
     QtGui.QMainWindow.__init__(self)
     self.databaseFilePath = "resources" +os.sep+ "database.db"
     self.database = niggerFiles.Students(self.databaseFilePath)
     self.configurator = config.configurator()
     self.iAmBoredPath = os.getcwd() + os.sep + "i am bored"
     self.widget = None
     self.setupStatusBar()
     self.setupMenuBar()
     self.setupCentralWidget()
     QtGui.QApplication.instance().setStyleSheet(self.configurator.applicationStyleSheet)
Ejemplo n.º 2
0
def main():
    options = config.configurator().parse_args()
    template = options.template_path
    nginx_conf_dir = options.output_dir
    api_url = options.api_url
    docker = DockerSpy(container_api_url=api_url)
    parser = TemplateParser(template_path=template)

    def _config_gen():
        """

        :rtype : object
        """
        for container in docker.describe_containers:
            # local vars to easy code management
            if 'VIRTUAL_HOST' in docker.containers[container]['Config'][
                    'Env'].keys():
                vhost = docker.containers[container]['Config']['Env'][
                    'VIRTUAL_HOST']
                port = docker.containers[container]['Config']['Env'][
                    'VIRTUAL_PORT']
                ip = docker.containers[container]['NetworkSettings'][
                    'IPAddress']
                # node name created based on containers name
                node_config_file = '/etc/nginx/conf.d/{0}.conf'.format(
                    container)
                data = parser.replace_data(ip=ip, vhost=vhost, port=port)
                with open(node_config_file, 'w+') as config_file:
                    config_file.write(data)

        call(['/etc/init.d/nginx', 'reload'])

    sys.stdout.write('dockerspy: Generating nodes config files')
    _config_gen()

    while True:
        for event in docker.events().__iter__():
            if event['status'] == 'start':
                sys.stdout.write(
                    'dockerspy: Generating nodes config files from started containers'
                )
                _config_gen()
            elif event['status'] == 'stop':
                sys.stdout.write(
                    'dockerspy: Generating nodes config files from stopped containers'
                )
                container_name = event['from'].split('/')[1] + '.conf'
                node = os.path.join(nginx_conf_dir, container_name)
                os.remove(node)
                call(['/etc/init.d/nginx', 'reload'])
Ejemplo n.º 3
0
	def __init__(self):
		self._lastId=0
		self.queue = {'socket':{},'commands':{}}
		self.cfg = config.configurator(self)
		self.conf = self.cfg.conf
		self.jid = xmpp.JID(self.conf['jid'])
		self.bot = xmpp.Client(self.jid.getDomain(),debug=[])

		
		self.socketInit()
		self.jabberInit()
		
		self.clients={}
		self.clients['jabber']={}
		config.d=self
Ejemplo n.º 4
0
def main():
    options = config.configurator().parse_args()
    template = options.template_path
    nginx_conf_dir = options.output_dir
    api_url = options.api_url
    docker = DockerSpy(container_api_url=api_url)
    parser = TemplateParser(template_path=template)

    def _config_gen():
        """

        :rtype : object
        """
        for container in docker.describe_containers:
            # local vars to easy code management
            if 'VIRTUAL_HOST' in docker.containers[container]['Config']['Env'].keys():
                vhost = docker.containers[container]['Config']['Env']['VIRTUAL_HOST']
                port = docker.containers[container]['Config']['Env']['VIRTUAL_PORT']
                ip = docker.containers[container]['NetworkSettings']['IPAddress']
                # node name created based on containers name
                node_config_file = '/etc/nginx/conf.d/{0}.conf'.format(container)
                data = parser.replace_data(ip=ip, vhost=vhost, port=port)
                with open(node_config_file, 'w+') as config_file:
                    config_file.write(data)

        call(['/etc/init.d/nginx', 'reload'])

    sys.stdout.write('dockerspy: Generating nodes config files')
    _config_gen()

    while True:
        for event in docker.events().__iter__():
            if event['status'] == 'start':
                sys.stdout.write('dockerspy: Generating nodes config files from started containers')
                _config_gen()
            elif event['status'] == 'stop':
                sys.stdout.write('dockerspy: Generating nodes config files from stopped containers')
                container_name = event['from'].split('/')[1] + '.conf'
                node = os.path.join(nginx_conf_dir, container_name)
                os.remove(node)
                call(['/etc/init.d/nginx', 'reload'])
Ejemplo n.º 5
0
class Connector:     
    # Load Configuration data from file
    cnfg=config.configurator("Config/FireTV.config")
    returned=cnfg.process()
    keys=returned[0]
    values=returned[1]
    configuration={}
    cnt=0
    """ Copy configuration into dictionary"""
    for item in keys:
        configuration[str(item)]=str(values[int(cnt)])
        cnt=cnt+1

    if configuration["DEBUG"]=="True":
        print("FireTVConnect: NOTE: DEBUG Mode enabled!")
        debug=True
    else:
        debug=False
    if configuration["SILENT"]=="True":
        silent=True
    else:
        silent=False


    KeyLibrary={"Up" : "19","Down" : "20","Left":"21","Right":"22","Enter":"66","Back":"4","Home":"3","Menu":"1","Play/Pause":"85","Previous":"88","Next":"87"}
    if debug==True: # If enabled by default, create a debug object
        db=debugger()
        db.alert("Creating adb object","Alert")
    adbclient=adb()
    if debug==True:
        db.alert("Created ADB object:","Alert")
        db.alert("Object info: "+str(adb),"Sub_alert")
    def __init__(self,ip_address,port=5555):
        self.ip_address=ip_address # Set the ip_address and port to the input values
        self.port=port
        if Connector.debug==True:
            self.db.alert("Created Connector Object:","Alert")
            self.db.alert(self,"Sub_alert")
            self.db.alert("Address: "+str(ip_address),"Sub_alert")
            self.db.alert("Port: "+str(port),"Sub_alert")
    def Connect(self):

        if Connector.debug==True:
            self.db.alert("Attempting to connect...","Alert")
            self.db.alert("Connecting to: "+str(self.ip_address)+":"+str(self.port),"Sub_alert")
        elif Connector.silent==False:
            print("Connecting to FireTv")
        cmd_res=self.adbclient.SendCMD("connect "+str(self.ip_address)+":"+str(self.port)) # Send a connect command using the adb client
        if not cmd_res==0: # If it returns anything but 0, give a warning about being unable to connect
            print("Unable to Connect to FireTV, am I on?")

        elif Connector.debug==True: # If the debugging is true, show debugging info
            self.db.alert("Connected FireTv from object with following information: ","Alert")
            self.db.alert("Address: "+str(self.ip_address),"Sub_alert")
            self.db.alert("Port: "+str(self.port),"Sub_alert")
        elif Connector.silent==False: # If not in silent mode, print connected
            print("Connected To FireTV!")
    def KeyEvent(self,event):
        if Connector.debug==True: # Give debugging information
            self.db.alert("Creating Key Event: ","Alert")
            self.db.alert("KeyEvent: "+str(event),"Sub_alert")
            self.db.alert("KeyCode: "+str(self.KeyLibrary[str(event)]),"Sub_alert")
        cmd_res=self.adbclient.SendCMD("shell input keyevent "+str(self.KeyLibrary[str(event)])) # Send a keyboard input event using the adb 
        if cmd_res==0:
            if Connector.debug==True:
                self.db.alert("Key Event Send Status: Sent (Success!)","Sub_alert")
            elif Connector.silent==False:
                print("KeyEvent has been sent")
        else:
            if Connector.debug==False:
                print("Unable to Send Key Event!")
                input("Press Enter to Exit")
                sys.exit(1)
            else:
                self.db.alert("Key Event Send Status: Unable to Send(FAIL)","Sub_alert")
    def Reset(self): 
        if Connector.debug==True:
            self.db.alert("Resetting adb server...","Alert")
        cmd_res=self.adbclient.SendCMD("disconnect") # Disconnect the current connection
        if not cmd_res==0:
            print("Unable to Reset Server: Disconnect Failed!")
            if Connector.debug==False:
                input("Press Enter to Exit")
                sys.exit(1)
        cmd_res=self.adbclient.SendCMD("kill-server") # Killoff the server
        if not cmd_res==0:
            print("Unable to Reset Server: Unable to Kill Server!")
            if Connector.debug==False:
                input("Press Enter to Exit")
                sys.exit(1)
        else:
            if Connector.debug==True:
                self.db.alert("Server has been Reset","Sub_alert")
    
    def LaunchApp(self,name,cmd):
        if Connector.debug==True:
            self.db.alert("Launching the following app: ","Alert")
            self.db.alert("App Name: "+str(name),"Sub_alert")
            self.db.alert("App Launch Point: "+str(cmd),"Sub_alert")
        elif Connector.silent==False:
            print("Launching app: "+str(name))
        cmd_res=self.adbclient.SendCMD("shell monkey -p "+str(cmd)+" -c android.intent.category.LAUNCHER 1") #Launch the given app
        if cmd_res==0:
            if Connector.debug==True:
                self.db.alert("Launch App Send Status: Sent (Success!)","Sub_alert")
            elif Connector.silent==False:
                print("App has been Launched")
        else:
            if Connector.debug==False:
                print("Unable to Send Launch App!")
                input("Press Enter to Exit")
                sys.exit(1)
            else:
                self.db.alert("Launch App Send Status: Unable to Send(FAIL)","Sub_alert")
Ejemplo n.º 6
0
        if os.path.exists(path):
          if not path in valid_paths:
            valid_paths.append(path)

    config.paths = '\n'.join(valid_paths)
    config.deep_search = int(user_data.deep_search)
    DBHelper().save_settings(config)
    params={
      'per_page':config.per_page,
      'paths':config.paths,
      'deep_search':config.deep_search
    }
    web.header('Content-Type', 'application/json')
    return json.dumps(params)


if __name__ == "__main__":

  urls = (
    '/', 'index',
    '/settings','settings',
    '/reload','libloader'
  )
  global config
  config = configurator()
  app = web.application(urls,globals())
  render = web.template.render('templates/', base='layout', 
    globals={'config':config})

  app.run()
Ejemplo n.º 7
0
from urllib import *
from urllib.request import Request , urlopen
import httplib2
import googleapiclient.discovery as discovery
from oauth2client import file, client, tools
import numpy as np

import jsonread
import config

CLIENT_SECRET = jsonread.get_path()+'/creds/client_secret.json'
SCOPE = 'https://www.googleapis.com/auth/spreadsheets'

# Overwrite None values later
ssId = config.configurator().spreadSheetId
if '\n' in ssId:
	ssId = ssId[:-1]
_SPREADSHEETID = ssId

# Start OAuth to retrive credentials

def refresh_access_token():
	with open("credentials.storage","r") as read_file:
		read_content = read_file.read()
		json_content = json.loads(read_content)

		client_id = json_content["client_id"]
		client_secret = json_content["client_secret"]
		refresh_token = json_content["refresh_token"]