Example #1
0
def main():
    for a in sys.argv:
        if a == '-v':
            print_version_and_exit()
    
    if len(sys.argv) < 2 or sys.argv[1] == '-h':
        print_usage_and_exit(0)
    
    load_settings()

    command = sys.argv[1]
    arg_parser = make_arg_parser(command)

    if command in ('startserver', 'stopserver'):
        import server
        server.main(arg_parser, sys.argv[2:], command[:-6])

    elif command == 'sendmail':
        import sendmail
        sendmail.main(arg_parser, sys.argv[2:])
    
    elif command == 'webhook':
        import webhook
        webhook.main(arg_parser, sys.argv[2:])

    elif command == 'shell':
        import shell
        shell.main(arg_parser, sys.argv[2:])

    else:
        sys.stderr.write('unknown command "%s"\n\n' % command)
        print_usage_and_exit(-1)
Example #2
0
 def _handler(self, event):
     pathname = event.pathname
     # isdir = os.path.isdir(pathname)
     if event.dir:
         logging.info('{0} dir:{1} at:{2}'.format(event.maskname, pathname,
                                                  datetime.now()))
     else:
         logging.info('{0} file:{1} at:{2}'.format(event.maskname, pathname,
                                                   datetime.now()))
         shell.main()
Example #3
0
 def _handler(self, event):
     pathname = event.pathname
     # isdir = os.path.isdir(pathname)
     if event.dir:
         logging.info(
             '{0} dir:{1} at:{2}'.format(
                 event.maskname,
                 pathname,
                 datetime.now()))
     else:
         logging.info('{0} file:{1} at:{2}'.format(
             event.maskname, pathname, datetime.now()))
         shell.main()
def main ( ):
#==========================================================================

	shell_misc.register()
	shell_help.register()
	shell_config.register()
	shell_create.register()
	shell_add.register()
	shell_remove.register()
	shell_rename.register()
	shell_update.register()
	shell_sync.register()

	shell.main()
Example #5
0
def main():
    for a in sys.argv:
        if a == '-v':
            print_version_and_exit()
    
    if len(sys.argv) < 2 or sys.argv[1] == '-h':
        print_usage_and_exit(0)
    
    load_settings()

    command = sys.argv[1]
    arg_parser = make_arg_parser(command)


    if command in ('startserver', 'stopserver'):
        import server
        server.main(arg_parser, sys.argv[2:], command[:-6])

    elif command == 'sendmail':
        import sendmail
        sendmail.main(arg_parser, sys.argv[2:])
    
    elif command == 'relayevent':
        import relayevent
        relayevent.main(arg_parser, sys.argv[2:])

    elif command == 'webhook':
        import webhook
        webhook.main(arg_parser, sys.argv[2:])

    elif command == 'shell':
        import shell
        shell.main(arg_parser, sys.argv[2:])

    else:
        sys.stderr.write('unknown command "%s"\n\n' % command)
        print_usage_and_exit(-1)
Example #6
0
    results[name] = {}
    results[name]['result'] = 0

    wrongs = {}

    for j in tests:
        f = open('out.txt', 'w')
        sys.stdout = f
        with open("result.kode", "w") as file:
            file.write(f'imports("{codes_path + i}")\n')
            file.write(f'print(solution({tests[j]["input"]}))')

        with open("output.txt", "w") as file:
            file.write(str(tests[j]["output"]))

        shell.main('run("result.kode")')
        f.flush()
        if compareFiles("out.txt", "output.txt"):
            results[name]['result'] += 1
        else:
            wrongs[j] = {}
            with open("out.txt", "r") as f:
                wrongs[j]['given'] = f.readline().strip()

            wrongs[j]['expected'] = tests[j]["output"]

        f.close()

    results[name]['wrongs'] = wrongs

    sys.stdout = resultsFile
Example #7
0
    def startState(self):
        # BEGIN_YOUR_CODE (our solution is 1 line of code, but don't worry if you deviate from this)
        raise Exception("Not implemented yet")
        # END_YOUR_CODE

    def isEnd(self, state):
        # BEGIN_YOUR_CODE (our solution is 2 lines of code, but don't worry if you deviate from this)
        raise Exception("Not implemented yet")
        # END_YOUR_CODE

    def succAndCost(self, state):
        # BEGIN_YOUR_CODE (our solution is 14 lines of code, but don't worry if you deviate from this)
        raise Exception("Not implemented yet")
        # END_YOUR_CODE


def segmentAndInsert(query, bigramCost, possibleFills):
    if len(query) == 0:
        return ''

    # BEGIN_YOUR_CODE (our solution is 4 lines of code, but don't worry if you deviate from this)
    raise Exception("Not implemented yet")
    # END_YOUR_CODE


############################################################

if __name__ == '__main__':
    shell.main()
Example #8
0
    print(f1)
    print(f2)

    if len(f1) - 1 > len(f2):
        raise Exception("Some test is wrong: " + file2 + "\n" + str(f1) + " " +
                        str(f2))

    for i in range(len(f2)):
        if f1[i] != f2[i]:
            raise Exception("Some line failed: " + file2 + "\n" + str(f1) +
                            " " + str(f2))


orig_stdout = sys.stdout
example_path = "examples/"

test_folders = list(
    filter(lambda x: len(x.split(".")) == 1, os.listdir('examples')))

for i in test_folders:
    f = open('out.txt', 'w')
    sys.stdout = f
    shell.main('run("' + example_path + i + '/code.pansy")')
    f.flush()
    compareFiles("out.txt", example_path + i + "/output.txt")
    f.close()

os.remove("out.txt")
sys.stdout = orig_stdout
print("All tests passed!")
def test_example2(output):
    shell.main()

    assert output == '''
def test_is_case_sensitive(output):
    shell.main()

    assert output == '''
Example #11
0
                yield ERROR, "FILE ERROR: {0}".format(self.error_msg())
                return

        yield MESSAGE, "Using packing algorithm '{0}' to generate packing".format(
            self.settings['algorithm'])

        if not self.pack(sprites):
            yield ERROR, "ALGORITHM ERROR: {0}".format(self.error_msg())
            # Keep going so the user can take a look at the output sprite

        yield MESSAGE, "Saving sprite '{0}'".format(
            self.settings['output_path'])

        if not self.save_sprite(sprites):
            yield ERROR, "SAVE ERROR: {0}".format(self.error_msg())
            return

        yield MESSAGE, "Saving plist file '{0}'".format(
            self.settings['plist_path'])

        if not self.save_plist(sprites, self.settings['plist_path']):
            yield ERROR, "PLIST ERROR: {0}".format(self.error_msg())
            return

        yield MESSAGE, "Done."


if __name__ == '__main__':
    from shell import main
    main(sys.argv[1:])
Example #12
0
    results[name] = {}
    results[name]['result'] = 0

    wrongs = {}

    for j in tests:
        f = open('out.txt', 'w')
        sys.stdout = f
        with open("result.pansy", "w") as file:
            file.write(f'imports("{codes_path + i}")\n')
            file.write(f'print(solution({tests[j]["input"]}))')

        with open("output.txt", "w") as file:
            file.write(str(tests[j]["output"]))

        shell.main('run("result.pansy")')
        f.flush()
        if compareFiles("out.txt", "output.txt"):
            results[name]['result'] += 1
        else:
            wrongs[j] = {}
            with open("out.txt", "r") as f:
                wrongs[j]['given'] = f.readline().strip()

            wrongs[j]['expected'] = tests[j]["output"]

        f.close()

    results[name]['wrongs'] = wrongs

    sys.stdout = resultsFile
Example #13
0
         functions.add_program(
             db.system_object,
             name,
             code
         )
 logging.info('Patching Lua globals...')
 programming.load_functions()
 logging.info('Done.')
 # Make sure the log function gets compiled:
 assert callable(db.system_object['log'])
 from monolith.log_handler import LogHandler
 logging.getLogger().addHandler(LogHandler())
 if args.shell:
     from shell import main
     try:
         main()
     except SystemExit:
         pass
 else:
     logging.info(
         'Listening for connections on %s:%d.',
         config.interface,
         config.port
     )
     reactor.listenTCP(
         config.port,
         networking.factory,
         interface=config.interface
     )
     reactor.run()
 dump_config()
Example #14
0
"""
.. module:: main
   :platform: Unix
      :synopsis: This is the entry point of the app

      .. moduleauthor:: Alexandros Ntavelos <*****@*****.**>

      """
from shell import main

if __name__ == '__main__':
    main()
Example #15
0
def get_item(output):
    shell.main()
    assert output == """ 
Example #16
0
def compareFiles(file1, file2):
    f1 = [line.replace('\n','') for line in open(file1).readlines()]
    f2 = [line.replace('\n','') for line in open(file2).readlines()]

    print(f1)
    print(f2)

    if len(f1) - 1 > len(f2):
        raise Exception("Some test is wrong: " + file2 + "\n" + str(f1) + " " + str(f2)) 

    for i in range(len(f2)):
        if f1[i] != f2[i]:
            raise Exception("Some line failed: " + file2 + "\n" + str(f1) + " " + str(f2))

orig_stdout = sys.stdout
example_path = "examples/"

test_folders = list(filter(lambda x: len(x.split(".")) == 1, os.listdir('examples')))

for i in test_folders:
    f = open('out.txt', 'w')
    sys.stdout = f
    shell.main('run("' + example_path + i + '/code.kode")')
    f.flush()
    compareFiles("out.txt", example_path + i +"/output.txt")
    f.close()
    
os.remove("out.txt")
sys.stdout = orig_stdout
print("All tests passed!")
Example #17
0
                sprites.append(sprite)
            else:
                yield ERROR, "FILE ERROR: {0}".format(self.error_msg())
                return
                        

        yield MESSAGE, "Using packing algorithm '{0}' to generate packing".format(self.settings['algorithm'])

        if not self.pack(sprites):
            yield ERROR, "ALGORITHM ERROR: {0}".format(self.error_msg())
            # Keep going so the user can take a look at the output sprite

        yield MESSAGE, "Saving sprite '{0}'".format(self.settings['output_path'])

        if not self.save_sprite(sprites):
            yield ERROR, "SAVE ERROR: {0}".format(self.error_msg())
            return

        yield MESSAGE, "Saving plist file '{0}'".format(self.settings['plist_path'])

        if not self.save_plist(sprites, self.settings['plist_path']):
            yield ERROR, "PLIST ERROR: {0}".format(self.error_msg())
            return 

        yield MESSAGE, "Done."
        

if __name__ == '__main__':
    from shell import main
    main(sys.argv[1:])
Example #18
0
		return index >= len(self.query)
		# END_YOUR_CODE

	def succAndCost(self, state):
		# BEGIN_YOUR_CODE (around 15 lines of code expected)
		choices = []
		q = self.query
		prevWord, currIndex = state
		for index in range(currIndex + 1, len(q) + 1):
			word = q[currIndex:index]
			possibles = self.possibleFills(word)
			for poss in possibles:
				choices.append((poss, (poss, index), self.bigramCost(prevWord, poss)))
		return choices
		# END_YOUR_CODE

def segmentAndInsert(query, bigramCost, possibleFills):
	if len(query) == 0:
		return ''

	# BEGIN_YOUR_CODE (around 5 lines of code expected)
	ucs = util.UniformCostSearch(verbose=0)
	ucs.solve(JointSegmentationInsertionProblem(query, bigramCost, possibleFills))
	return ' '.join(ucs.actions)
	# END_YOUR_CODE

############################################################

if __name__ == '__main__':
	shell.main()
Example #19
0
# -*- coding: utf-8 -*-
import socks
import socket
import shell
import sys

if __name__ == '__main__':
    # подключаемся к Tor
    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9150)
    socket.socket = socks.socksocket
    shell.main(sys.argv[1], sys.argv[2])