コード例 #1
0
ファイル: deletes.py プロジェクト: ephur/crud_config
def delete_main(path):
    valid_keys = ['containers', 'keyvals']
    try:
        container = ccget.get_container(path)
    except ce.noResult:
        return(error(
               404,
               "Container you want to delete from is not found",
               requested_container_tree=" -> ".join(path.split("/"))))

    # Check the validity of request
    if len(flask.request.args) > 0:
        return(error(
               400,
               "DELETE requests should not have querystring params",
               querystring_params=flask.request.args))

    # Load the JSON data, and validate it
    try:
        request_data = json.loads(flask.request.get_data())
    except json.JSONDecodeError as e:
        return(error(
               400,
               "JSON Data is invalid",
               escaped_data_submitted=flask.request.get_data(),
               parsing_error=e.message))

    # Check for invalid keys
    for key in sorted(request_data.keys()):
        if key not in valid_keys:
            return(error(
                   400,
                   "JSON contained bad key",
                   errored_on_key=key))

    return_data = list()
    for key in valid_keys:
        try:
            local_data = request_data[key]
        except (KeyError) as e:
            continue
        return_data = globals()["delete_process_" + key](
            local_data,
            container_id=container.id,
            processed_so_far=return_data,
            path=path)

        # Return data will become a TUPLE if there was a processing error, in
        # which case we need to return this back up the stack
        if type(return_data) is tuple:
            return return_data

    # Time to clean up the caches...
    # post_invalidate_cache(path, request_data)
    purge(path, request_data)
    return json.dumps({"results": return_data})
コード例 #2
0
ファイル: puts.py プロジェクト: mike6856/crud_config
def put_main(path):
    # A function that matches post_process_{valid_key} must exist
    valid_keys = ['containers', 'keyvals']
    try:
        container = ccget.get_container(path)
    except ce.noResult:
        return(error(
               404,
               "Container you want to PUT into is not found",
               requested_container_tree=" -> ".join(path.split("/"))))

    # Check the validity of request
    if len(flask.request.args) > 0:
        return(error(
               400,
               "PUT requests should not have querystring params",
               querystring_params=flask.request.args))

    # Load the JSON data, and validate it
    try:
        request_data = json.loads(flask.request.get_data())
    except json.JSONDecodeError as e:
        return(error(
               400,
               "JSON Data is invalid",
               escaped_data_submitted=flask.request.get_data(),
               parsing_error=e.message))

    # Check for invalid keys
    for key in sorted(request_data.keys()):
        if key not in valid_keys:
            return(error(
                   400,
                   "JSON contained bad key",
                   errored_on_key=key))

    return_data = list()
    for key in valid_keys:
        try:
            local_data = request_data[key]
        except (KeyError) as e:
            continue
        return_data = globals()["put_process_" + key](
            local_data,
            path=path,
            container_id=container.id,
            processed_so_far=return_data)

        # Return data will become a TUPLE if there was a processing error, in
        # which case we need to return this back up the stack
        if type(return_data) is tuple:
            return return_data

    # Time to clean up the caches...
    purge(path, request_data)
    return json.dumps({"results": return_data})
コード例 #3
0
 def test_purge(self):
     shutil.move("/home/josh/Workspace/Scanner3D/TestPics/tears.jpg",
                 "/home/josh/Workspace/Scanner3D/images/")
     purge("images")
     self.assertEqual(os.listdir('images'), [])
コード例 #4
0
 def test_img_converter(self):
     purge("images")
     img_converter('test.mp4')
     self.assertNotEqual(os.listdir('images'), [])
コード例 #5
0

if __name__ == "__main__":
    qlist, alist = list(), list()
    emotag = EmoTagger()
    dic = _createMovieLineDict()
    emodic = _createEmoDict()
    movielines = _createCovlist()
    # baseline model
    for l in movielines:
        x = l.split("+++$+++")
        conv = ast.literal_eval(x[3].strip())
        for i in range(0, len(conv) - 1):
            if "<nos>" in dic[conv[i]] or "<nos>" in dic[conv[i + 1]]:
                continue
            qlist.append(purge.purge(dic[conv[i]]))
            alist.append(purge.purge(dic[conv[i + 1]]))
    _savefile("baseline", qlist, alist)
    # tag pos
    # to let people know the program is not dead but painfully slow
    poscount = 0
    for l in movielines:
        x = l.split("+++$+++")
        conv = ast.literal_eval(x[3].strip())
        for i in range(0, len(conv) - 1):
            if "<nos>" in dic[conv[i]] or "<nos>" in dic[conv[i + 1]]:
                continue
            poscount += 1
            qlist.append(tagpos(purge.purge(dic[conv[i]])))
            alist.append(tagpos(purge.purge(dic[conv[i + 1]])))
            print(poscount)
コード例 #6
0
    async def commandParser(self, message, globalCall):

        messageContent = message.content.lower()

        # Casino Module
        if (messageContent.startswith(globalCall + "c ")):
            gambleTime = CasinoModule()
            await gambleTime.commandReciever(message)
            return

        # Help message
        if (messageContent == globalCall + "help"):
            myHelp = help()
            await myHelp.myEmbed(message)
            return

        # Convert Currency
        if (messageContent.startswith(globalCall + "currency")):
            newCurrency = currency()
            await newCurrency.currencyConverter(message)
            return

        # Search workshop
        if (messageContent.startswith((globalCall + 'sws'))):
            searchWorkshop = sws()
            await message.channel.send("Searching the workshop. Please wait..."
                                       )
            searchIt = searchWorkshop.theMain(message.content)
            if not searchIt:
                await message.channel.send(
                    "That's a fat error from me dawg. The search came up empty."
                )
                return
            else:
                await message.channel.send(searchIt)
                return

        # Get random Seinfeld quote
        if (messageContent.startswith((globalCall + 'seinfeldme'))):
            getSeinfeldQuote = seinfeldme()
            await getSeinfeldQuote.getQuote(message)
            return

        # Get random ketal quote
        if (messageContent.startswith((globalCall + 'ketalquote'))):
            getKetalQuote = ketalquote()
            await getKetalQuote.getQuote(message)
            return

        # Get random Squidski fact
        if (messageContent.startswith((globalCall + 'squidskifact'))):
            squidFact = squidskifact()
            await squidFact.getQuote(message)
            return

        # Give/Remove Pings role
        if (messageContent.startswith((globalCall + 'pings'))):
            myPings = pings()
            await myPings.changePingRoleState(message)
            return

        # Admin only commands (Administrator only)
        if (((messageContent).split(" "))[0].startswith(globalCall +
                                                        "helpadmin")):
            myAdminCommands = helpadmin()
            await myAdminCommands.checkPerms(message)
            return

        # Purge messages (Administrator Only)
        if (((messageContent).split(" "))[0].startswith(globalCall + "purge")):
            myPurge = purge()
            await myPurge.purger(message)
            return

        # Ping the Pings role (Administrator Only)
        if (messageContent.startswith((globalCall + 'rolepinger'))):
            myPinger = rolepinger()
            await myPinger.pinger(message)
            return

        # Mute a bad user (Administrator Only)
        if (messageContent.startswith((globalCall + 'mute'))):
            myMuter = mute()
            await myMuter.mute_users(message)
            return

        # Checks if is bruh moment
        if (messageContent.startswith((globalCall + 'bruhmoment'))):
            myBruh = bruhmoment()
            await myBruh.isBruhMoment(message)
            return

    # Searches the Steam Workshop via the API
        if (messageContent.startswith((globalCall + 'wtest'))):
            mySAPI = apiworkshopsearch()
            args = message.content.split(" ")
            await mySAPI.requestInfo(message, args[1], " ".join(args[2:]))
            return

        # Pulls a random line from the Source Engine fanfictions
        if (messageContent.startswith((globalCall + 'fanfic'))):
            getFanfic = fanfic()
            await getFanfic.getLine(message)
            return

        # Search VDC
        if (messageContent.startswith((globalCall + 'v'))):
            searchVDC = VDCsearch()
            await searchVDC.searchTheVDC(message)
            return
コード例 #7
0
f = open('stored.mp4','wb')
s.listen(5)
while True:
	print 'waiting'
	c, addr = s.accept()
	print 'Connected to', addr
	f = open('stored.mp4','wb')
	packet = c.recv(1024)
	print 'receiving video ...'
	while(packet):
		f.write(packet)
		packet = c.recv(1024)
	f.close()
	print 'Video Received'
	print 'purge old images...'
	purge('images')
	img_converter('stored.mp4')
	check that ROS is running on the server
	print 'checking ROS...'
	checkROS()
	time.sleep(20)
	create_bag()
	play_bag() 
	print 'making stl' 
	#time.sleep(60)
	buffer = "Read buffer:\n"
	buffer += open('Nuke-Cola.SLDASM', 'rU').read()
	print 'sending stl man'	
	c.sendall(buffer)	
	c.close()
コード例 #8
0
ファイル: tests.py プロジェクト: Loeing/3DScanner_Server
 def test_purge(self):
     shutil.move("/home/josh/Workspace/Scanner3D/TestPics/tears.jpg", "/home/josh/Workspace/Scanner3D/images/")
     purge("images")
     self.assertEqual(os.listdir('images'),[])
コード例 #9
0
ファイル: tests.py プロジェクト: Loeing/3DScanner_Server
 def test_img_converter(self):
     purge("images")
     img_converter('test.mp4')
     self.assertNotEqual(os.listdir('images'),[])
コード例 #10
0
ファイル: process_all.py プロジェクト: tomasvdw/btcsoccer
while True:

    # turn off signals during processing
    libc.sighold(signal.SIGKILL)
    libc.sighold(signal.SIGTERM)
    libc.sighold(signal.SIGINT)
    libc.sighold(signal.SIGHUP)

    try:
        load_games.get_matches()
        process_btc_incoming.process_incoming_all()
        process_btc_outgoing.process_outgoing_all()  
        generate_var.generate_pub()
        generate_chat.generate_chat()
        purge.purge()
    except Exception, e:
        logging.exception('Error during btcs processing')
        raise e

    libc.sigrelse(signal.SIGKILL)
    libc.sigrelse(signal.SIGTERM)
    libc.sigrelse(signal.SIGINT)
    libc.sigrelse(signal.SIGHUP)

    if os.path.exists('../stopmark'):
        logging.info('Clean shutdown initiated')
        os.remove('../stopmark')
        break

    time.sleep(5)