Ejemplo n.º 1
0
def compilepackage(tree):
    buildNode = tree.getroot().find("build")

    commands.chdir("build")
    # Build the package
    for i in buildNode:
        if i.tag == "command":
            commands.command(i.text)
    commands.chdir("..")
Ejemplo n.º 2
0
def compilepackage(tree):
    buildNode = tree.getroot().find("build")

    commands.chdir("build")
    # Build the package
    for i in buildNode:
        if i.tag == "command":
            commands.command(i.text)
    commands.chdir("..")
Ejemplo n.º 3
0
def swarm():
    init_command = "bash ./multi-setup.sh {}".format(localip)
    # leaving swarm
    command(init_command)[1]
    join_token = command("docker swarm join-token manager")[1]
    for i in join_token.split("\n"):
        if i.find("SWMTKN") > -1:
            join_token = i
            print(join_token)
    return
Ejemplo n.º 4
0
def interprete(ff_qry):
    words = ff_qry.split(";")
    cmds = valid_commands(words)
    print(cmds)
    if (len(cmds)):
        for cmd in cmds:
            if (command(cmd)):
                command(cmd)
            else:
                print(cmd + " command not found..")
    return 1
Ejemplo n.º 5
0
def interprete(ff_qry):
    words = ff_qry.split(";")
    cmds = valid_commands(words)
    #rels = valid_relations(words)
    #objs = valid_objects(words)
    #bots = valid_bots(words)

    if (len(cmds)):
        for cmd in cmds:
            if (command(cmd)):
                command(cmd)

    return 1
Ejemplo n.º 6
0
def last_commit(repopath):
    """ Gets the last commit information.
        This can be used to verify the latest commit
    """
    command = "cd %s; git log -1i --date=iso" % repopath
    out = run.command(command)
    if out:
        creg = re.compile(r"commit\s+(?P<remote_host>([a-f0-9]+))") # Commitid
        areg = re.compile(r"Author:\s+(?P<author>(.*$))") # author
        dreg = re.compile(r"Date:\s+(?P<date>(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}))") # Date
        last = {}

        for line in out.splitlines():
            commit = creg.search(line)
            author = areg.search(line)
            date = dreg.search(line)
            if commit:
                last['id'] = commit.group(1)
            elif author:
                last['author'] = author.group(1)
            elif date:
                last['date'] = date.group(1)

        return last
    else:
        return None
Ejemplo n.º 7
0
def downloadpackage(tree):
    # Check if the source is already available
    download = tree.getroot().find("download")

    commands.chdir("build")
    if os.path.exists(download.find("result").text):
        print "Source for '%s' already downloaded" % package
    else:
        for i in download:
            if i.tag == "command":
                commands.command(i.text)
        commands.git_create_repo()
        for i in download:
            if i.tag == "patch":
                commands.git_apply_patch("../%s" % i.text)
    commands.chdir("..")
Ejemplo n.º 8
0
def downloadpackage(tree):
    # Check if the source is already available
    download = tree.getroot().find("download")

    commands.chdir("build")
    if os.path.exists(download.find("result").text):
        print "Source for '%s' already downloaded" % package
    else:
        for i in download:
            if i.tag == "command":
                commands.command(i.text)
        commands.git_create_repo()
        for i in download:
            if i.tag == "patch":
                commands.git_apply_patch("../%s" % i.text)
    commands.chdir("..")
Ejemplo n.º 9
0
def update(repopath, updatebranch="master"):
    """ Updates the branch by the given path and branch
        Can run update on remote branches
    """
    logging.debug("updating repo: %s, %s" % (repopath, updatebranch))
    if branch(repopath, updatebranch):
        repo = repopath.split(':')
        if len(repo) == 2:
            repopath = repo[1]

        command = "cd %s; git pull origin %s" % (repopath, updatebranch)

        if len(repo) == 1:
            out = run.command(command)
        elif len(repo) == 2:
            out = run.remote_command(repo[0], command)

        if out:
            for line in out.splitlines():
                logging.debug("OUTPUT" + line)
                if "Fast forward" in line:
                    return "Updated"
                elif "Already up-to-date." in line:
                    return "Newest"
                else:
                    return "WARN: %s" % line
    else:
        return None
Ejemplo n.º 10
0
 def handler(self, msg, msgId):
   fuin = msg['value']['from_uin']
   cmd=msg['value']['content'][1:]
   scmd="".join([x.decode('utf8').strip() for x in cmd if isinstance(x,unicode)])
   icmd="_".join([str(x[1]) for x in cmd if isinstance(x,list)])
   ret=commands.command(scmd=scmd,icmd=icmd)
   ret = ret.replace('\\', '\\\\\\\\').replace('\t', '\\\\t').replace('\r', '\\\\r').replace('\n', '\\\\n')
   ret = ret.replace('"', '\\\\\\"')
   self.Post("http://w.qq.com/d/channel/send_buddy_msg2", (
     ('r', '{{"to":{0},"face":567,"content":"[\\"{4}\\",[\\"font\\",{{\\"name\\":\\"Arial\\",\\"size\\":\\"10\\",\\"style\\":[0,0,0],\\"color\\":\\"000000\\"}}]]","msg_id":{1},"clientid":"{2}","psessionid":"{3}"}}'.format(fuin, msgId, self.ClientID, self.PSessionID, ret)),
     ('clientid', self.ClientID),
     ('psessionid', self.PSessionID)
   ), self.Referer)
Ejemplo n.º 11
0
def packagepackage(tree, package, devMode):
    # Build a string for the command to execute
    command = "blackberry-nativepackager"

    # Package name
    command += " %s.bar ../../blackberry-tablet.xml" % package

    packageNode = tree.getroot().find("package")
    commands.chdir("build/" + platform)
    if (devMode):
        command += " -devMode"
    for i in packageNode:
        if i.tag == "file":
            remote = i.get("remote")
            if remote:
                target = remote
            else:
                target = i.text

            command += " -e \"%s\" %s" % (os.path.expandvars(i.text), target)
        elif i.tag == "argument":
            command += " -arg \"%s\"" % i.text
    commands.command(command)
    commands.chdir("../..")
Ejemplo n.º 12
0
def packagepackage(tree, package, devMode):
    # Build a string for the command to execute
    command = "blackberry-nativepackager"

    # Package name
    command += " %s.bar ../../blackberry-tablet.xml" % package

    packageNode = tree.getroot().find("package")
    commands.chdir("build/"+platform)
    if( devMode ):
        command += " -devMode"
    for i in packageNode:
        if i.tag == "file":
            remote = i.get("remote")
            if remote:
                target = remote
            else:
                target = i.text

            command += " -e \"%s\" %s" % (os.path.expandvars(i.text), target)
        elif i.tag == "argument":
            command += " -arg \"%s\"" % i.text
    commands.command(command)
    commands.chdir("../..")
Ejemplo n.º 13
0
def branch(repopath, expected="master"):
    """ Checks the current branch of a repo.
        If branch == expected => True
    """
    repo = repopath.split(':')
    if len(repo) == 2:
        repopath = repo[1]
    command = "cd %s; git branch | grep \* | cut -d ' ' -f2" % repopath
    if len(repo) == 1:
        out = run.command(command)
    elif len(repo) == 2:
        out = run.remote_command(repo[0], command)

    if out:
        if expected in out:
            return True
        else:
            return False
    else:
        return None
Ejemplo n.º 14
0
def from_terminal_play():
    print terminal_formatting(directory[player.location].describe())
    while True:
        output = commands.command(commands.input_format(raw_input(">")), player)
        print terminal_formatting(output)
Ejemplo n.º 15
0
 def on_submission(instance):
     global widget_set, data_sources
     widget_set["log"].text += "You: " + instance.text + "\n"
     commands.command(instance.text, widget_set["log"], data_sources)
     widget_set["log"].text += "\n"
Ejemplo n.º 16
0
def main():

    if sys.version_info < (3, 0):
        sys.stderr.write("\nYou need python 3.0 or later to run this script\n")
        sys.stderr.write("Please update and make sure you use the command " +
                         '\033[1m' + "python3 ikimaru.py" + '\033[0m' + "\n\n")
        sys.exit(0)

    try:

        os.system('clear')
        welcome()
        animation()

        userArgv = input('-> ')
        print(Style.RESET_ALL)

        usA1 = userArgv.split(" ")[0]
        split = (len(userArgv.split(" ")))
        if split >= 2:
            usA2 = userArgv.split(" ")[1]

        if (len(userArgv) > 1) and userArgv.startswith('-'):
            if userArgv == "--help" or userArgv == '-h':
                os.system('clear')
                welcome()
                help(userArgv)

            elif userArgv == '-b' or userArgv == '--banner':
                os.system('clear')
                welcome()
            elif userArgv == '-c' or userArgv == '--commands':
                os.system('clear')
                welcome()
                listCommand()

        elif userArgv == 'fullcontact' or userArgv == '-f':
            fullcontact()

        elif userArgv == 'localhost':
            ip = myIp()
            os.system('clear')
            welcome()
            userArgv = ip
            getGeo(userArgv)
            check(userArgv)

        else:
            if usA1 == str:
                sys.exit(0)

            else:
                os.system('clear')
                welcome()
                print(Fore.CYAN + 'Wait a minute.....')
                getGeo(usA1)
                check(usA1)
                if (len(userArgv.split(" ")) > 1):
                    usA1 = userArgv.split(" ")[0]
                    usA2 = userArgv.split(" ")[1]
                    command(usA2, usA1)

    except KeyboardInterrupt:
        os.system('clear')
        welcome()
        keyCenter = "The program was interrupted by the user's keyboard. I hope to see you soon :)\n".center(
            85)
        print(keyCenter)
Ejemplo n.º 17
0
def ssh_join():
    cmd_1 = "ssh root@{} -i ~/.ssh/id_rsa \"uname -a \""
    print command(cmd_1)[1]
Ejemplo n.º 18
0
 def on_submission(instance):
     global widget_set
     widget_set["activity"].background_color = '#00e846'
     widget_set["log"].text += "You: " + instance.text + "\n"
     commands.command(instance.text, widget_set["log"])
Created by Gareth Johnson
Copyright (c) 2014 Beckersweet. All rights reserved.
"""

from commands import getoutput as command
from json import loads as decodeJSON
from json import dumps as encodeJSON
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import Node, RemoteController, CPULimitedHost
from mininet.util import pmonitor
import pp
from re import findall as find

ifconfig = command('ifconfig')
try:
	localIp = find('addr:(192\.168\.56\.\d+) ', ifconfig)[0]
except:
	print "Network settings not configured. Try running 'sudo dhclient eth1'."

NETWORK_CONTROLLER_PORT = 6633
NUMBER_OF_HOSTS = 3
TCP_REQUEST_COMMAND = "python tcpRequest.py " + localIp + " 9999 "
JOB_SERVER_COMMAND = "sudo python dynamic_ncpus.py "
BENCHMARK_RESULTS_FILE_NAME = "OpMub_benchmarking.out"

print
print "Creating network:"

virtualNetwork = Mininet(controller=RemoteController,
Ejemplo n.º 20
0
 def command(self, **kwargs):
     return commands.command(registry=self.commands, **kwargs)
Ejemplo n.º 21
0
def play_web(flask_input):
    return commands.command(commands.input_format(flask_input), player), directory[player.location].name
Ejemplo n.º 22
0
Created by Gareth Johnson
Copyright (c) 2014 Beckersweet. All rights reserved.
"""

from commands import getoutput as command
from json import loads as decodeJSON
from json import dumps as encodeJSON
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import Node, RemoteController, CPULimitedHost
from mininet.util import pmonitor
import pp
from re import findall as find

ifconfig = command('ifconfig')
try:
    localIp = find('addr:(192\.168\.56\.\d+) ', ifconfig)[0]
except:
    print "Network settings not configured. Try running 'sudo dhclient eth1'."

NETWORK_CONTROLLER_PORT = 6633
NUMBER_OF_HOSTS = 3
TCP_REQUEST_COMMAND = "python tcpRequest.py " + localIp + " 9999 "
JOB_SERVER_COMMAND = "sudo python dynamic_ncpus.py "
BENCHMARK_RESULTS_FILE_NAME = "OpMub_benchmarking.out"

print
print "Creating network:"

virtualNetwork = Mininet(controller=RemoteController,
Ejemplo n.º 23
0
import socket 
import commands
import inspect 

# Creates an instance of command class under commands.py
getCommand = commands.command()

# Stores all the commands
commandsList = []

# Retrieves all the methods from commands.py to make a list of callable commands
def retrieveCommandList():
    for x in inspect.getmembers(commands.command, inspect.ismethod):
    	commandsList.append(x[0])

retrieveCommandList()

# Class that connects to server and retrieves/sends
class connect:

    def __init__(self, server, channel, botnick, port):
		ircsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		ircsocket.connect((server, 6667)) 
		ircsocket.send("USER "+ botnick +" "+ botnick +" "+ botnick + " " + botnick + "\n")
		ircsocket.send("NICK "+ botnick +"\n") 
		ircsocket.send("JOIN "+ channel +"\n")

		# Loop that runs while the bot is active
		while 1:
			ircmsg = ircsocket.recv(2048) 
			ircmsg = ircmsg.strip('\n\r')