示例#1
0
    def get_string_source(self):
        import os
        import platform

        # import pdb; pdb.set_trace()

        cmdline = None
        if platform.system() == 'Windows':
            # TODO use winapi to obtain the command line
            return ''
        elif platform.system() == 'Linux':
            # TODO try to use proc
            pass

        if cmdline is None and os.name == 'posix':
            from subprocess import CalledProcessError, check_output as spawn

            try:
                cmdline = spawn(
                    ['ps', '-ww', '-p',
                     str(os.getpid()), '-o', 'command='])
            except CalledProcessError:
                return ''
        else:
            # current system doesn't have a way to get the command line
            return ''

        cmdline = cmdline.decode('utf-8').strip()
        cmdline = self.split_cmdline(cmdline)

        extra_args = sys.argv[1:]
        if len(extra_args) > 0:
            if cmdline[-len(extra_args):] != extra_args:
                # we can't rely on the output to be correct; fail!
                return ''

            cmdline = cmdline[1:-len(extra_args)]

        skip = 0
        for i in range(len(cmdline)):
            a = cmdline[i].strip()
            if not a.startswith('-c'):
                skip += 1
            else:
                a = a[2:].strip()
                if len(a) > 0:
                    cmdline[i] = a
                else:
                    skip += 1
                break

        cmdline = cmdline[skip:]
        source = ' '.join(cmdline)

        return source
示例#2
0
def run(command, dir=None, shell=False, stderr=False):
    proc = spawn(
        shlexSplit(command),
        cwd=dir,
        shell=shell,
        timeout=1,
        text=True,
        stdout=PIPE,
        stderr=PIPE,
    )
    if stderr:
        return proc.stderr.strip()
    else:
        return proc.stdout.strip()
示例#3
0
    def run(self):
        """Run this command, i.e. do the actual document generation."""

        sphinx = find_executable('sphinx-build')
        if sphinx:
            sphinx = [sphinx]
        else:
            try:  # try to find version installed with Python tools
                  # tested with Sphinx 1.1.3
                import sphinx as sp
            except ImportError:
                pass
            else:
                sphinx = [sys.executable, sp.__file__]

        if not sphinx:
            self.warn("could not find sphinx-build in PATH")
            self.warn("cannot build documentation")
            return

        doc_dir = os.path.join('share', 'doc', 'roundup', 'html')
        temp_dir = os.path.join(self.build_temp, 'doc')
        cmd = sphinx + ['-d', temp_dir, 'doc', doc_dir]
        spawn(cmd)
define the agent and the behavior tha agent will preform
define an application class for the agent to act on the behavior it will recieve
define webscraping most likely with scrapy
define storage of archived material probably with mongodb
define mathematics agent(for complex math required by other fuinctions to call from)
define text interface for communication between node and master agents and the user
if not included define communication between nodes 


define MendicantBot():
	Master bot, run when program starts and call from botmanager
	define control system that talks to BotManager
	call BotManager to spawn a node for a particular task that it oversees 
# Functions below except maybe botmanger call all from another file
define BotManager():
	subprocess.spawn(MendicantBotNode) #spawns MendicantBotNodes
		define agent type from a list of possible agents
		Popen.
		define communication between bots and MendicantBot

define MendicantBotInstance():
	call functions from another file

define math():
	here all the different types of math to do and they can all go in one function

define MendicantArchive():
	where data the bot has scraped is stored for recall later