Example #1
0
def client(request):
	my_client = WSClient.Client()
	host = pytest.config.getvalue('host')
	port = int(pytest.config.getvalue('port'))
	dontrunserver = pytest.config.getvalue('dontrunserver')
	server = pytest.config.getvalue('server')
	jsconfig = pytest.config.getvalue('jsconfig')
	if not dontrunserver:
		pid = util.start(server, server, '-c', jsconfig)
	time.sleep(0.05) # Give the child process a chance to run
	my_client.open(host, port)
	def fin():
		my_client.close()
		if not dontrunserver:
			util.stop(pid)
	request.addfinalizer(fin)
	return my_client
Example #2
0
        SecurityCodes = position['SecurityCode']
        HoldingValues = position['HoldingValue']
        capital_res = w.tquery("Capital", "LogonID=%s" % self.LogonID)
        capital = position_parser(capital_res)
        AvailableFund = capital['AvailableFund'][0]

        old_position = dict()
        for ticker, value in zip(SecurityCodes, HoldingValues):
            old_position[ticker] = value
        old_position[CASH] = AvailableFund
        return old_position

    def start(self):
        self.active = True
        self.thread.run()

    def stop(self):
        self.active = False
        self.thread.join()

    @staticmethod
    def round_down(x):
        return int(math.floor(x / 100)) * 100
if __name__ == "__main__":
    start()
    a = Strategy(trading_engine=None)
    a.before_trading()
    for event in a.generate_events(feed=None):
        print(event.dict)
Example #3
0
File: analyse.py Project: qll/shit
             'help': 'Python expression, like "value ^ 177"'},
            {'name': 'img_path', 'metavar': 'IMAGE_PATH',
             'help': 'Input image path'},
            {'name': 'out_path', 'metavar': 'OUTPUT_PATH',
             'help': 'Output image path'},
        )
    },
    'palette': {
        'function': fix_palette,
        'arguments': (
            {'name': 'img_path', 'metavar': 'IMAGE_PATH',
             'help': 'Path to suspected steganographic image'},
            {'name': 'out_path', 'metavar': 'OUTPUT_PATH',
             'help': 'File output path with changed color palette'},
        )
    },
    'strings': {
        'function': find_strings,
        'arguments': (
            {'name': 'img_path', 'metavar': 'IMAGE_PATH',
             'help': 'Path to suspected steganographic image'},
            {'flags': ('-t', '--threshold'), 'type': int, 'default': 4,
             'help': 'Print any sequence of at least X printables'},
        )
    },
}


if __name__ == '__main__':
    util.start(__doc__, METHODS)
Example #4
0
    },
    'patchwork': {
        'function':
        encode_patchwork,
        'arguments': ({
            'name': 'inp',
            'metavar': 'input_path',
            'help': 'Path to input image'
        }, {
            'name': 'out',
            'metavar': 'output_path',
            'help': 'Path to output image'
        }, {
            'name': 'msg',
            'metavar': 'message',
            'help': 'Message to hide in image'
        })
    }
}

if __name__ == '__main__':
    util.start(__doc__, METHODS)

#ex: python hide.py patchwork input.png output.png "msg"
# path = "C:\\Users\\juckef34\\ss15\\project\\tests\\files\\diffpixels.png"
# path2 = "C:\\Users\\juckef34\\ss15\\project\\tests\\files\\diffpixels_test.png"
# msg = "Nico ist toll"
# stegobit = 7

# bit(path, path2, msg, stegobit)
Example #5
0
print("Merged " + str(len(files)) + " filtered files")
print(
    str(len(papers)) + " papers and " + str(len(journals)) +
    " journals/venues")

#Counting papers per journal/venue
for p in papers:
    kj, kv = p.get("journalId"), p.get("venueId")
    if kj == kv and kj != "":
        journals[kj]['count'] += 1
    elif kv != "":
        journals[kv]['count'] += 1
    elif kj != "":
        journals[kj]['count'] += 1

u.start()

print("Computing journal/venue score")
papjv, papers = u.get_papjv(papers)
PTIds, maxy = u.getPaperSet(papers)
journals = u.count_j(papers, papjv, journals)
print("Updated journal dict:")
print(journals)

print(
    str(len(papers)) + " papers from 1995 to " + str(maxy) +
    " collected. Starting papers' file creation...")
pTestingJSON, citations = u.getPapersTestingJSON(papers, PTIds)
u.papersTestingForSearchFile(destination_path, pTestingJSON, citations)

### Create and write the authors' dataset
if_ppp = [if_ppp4, if_ppp6]

if_ipip6 = {4: 'ipip6'}

ipip6_endpoints = [
    'ip-in-ip-tunnel-endpoint.example.knorrie.org',
]

ipip6_ptp = [
    '10.252.0.3',
]

#########################################################################
# Default Rules

fw.add(util.start('INPUT'))
fw.add(util.start('FORWARD'))
fw.add(util.start('OUTPUT'))
r, h = util.input_lo()
fw.add(r)
ha.add(h)
fw.add(util.output_lo())

#########################################################################
# PREROUTING

r = oinkwall.IPTablesRuleset('nat', 'PREROUTING')
r.add(i=if_ppp4, d=ip_ppp4,
      r='-p tcp -m tcp --dport 26540 -j DNAT --to %s' % ip_that_we_nat_something_to)
fw.add(r)
Example #7
0
#!/usr/bin/python

# This is an example of a really simple firewall that only
# filters incoming traffic.

import oinkwall
import util

fw = oinkwall.IPTables()
ha = oinkwall.HostsAllow()

fw.add(util.start('INPUT'))

r, h = util.input_lo()
fw.add(r)
ha.add(h)

r = oinkwall.IPTablesRuleset('filter', 'INPUT')
r.add(comment="This is a comment",
      s=[
          'somehost.example.knorrie.org',
          'v4only.example.knorrie.org',
      ],
      r='-p tcp -m tcp --dport 25 -j ACCEPT')
r.add(r='-p tcp -m tcp --dport 80 -j ACCEPT')
fw.add(r)

r = oinkwall.IPTablesRuleset('filter', 'FORWARD')
r.add(s=['_net.another-example.knorrie.org', '2001:db8:77:88::99'],
      d='example.knorrie.org', r='-p tcp -m tcp --dport 443 -j ACCEPT')
fw.add(r)