Exemple #1
0
def cmd_maki(main_window, argv):
    """ /maki [connect|shutdown] """

    def usage():
        print_notification("Usage: /maki [connect|disconnect|shutdown]")

    if len(argv) != 2:
        usage()
        return

    cmd = argv[1]

    if cmd == "connect":
        print_notification("Connection to maki...")

        if connection.connect():
            print_notification("Connection to maki etablished.")
        else:
            print_notification("Connection to maki failed.")
        main_window.update_divider()

    elif cmd == "disconnect":
        if no_connection():
            return

        connection.disconnect()
        print_notification("Disconnected from maki.")
        main_window.update_divider()

    elif cmd == "shutdown":
        if no_connection():
            return

        connection.sushi.shutdown(config.get("chatting", "quit_message"))
        main_window.update_divider()

    else:
        usage()
        return
Exemple #2
0
def cmd_maki(main_window, argv):
    """ /maki [connect|shutdown] """
    def usage():
        print_notification("Usage: /maki [connect|disconnect|shutdown]")

    if len(argv) != 2:
        usage()
        return

    cmd = argv[1]

    if cmd == "connect":
        print_notification("Connection to maki...")

        if connection.connect():
            print_notification("Connection to maki etablished.")
        else:
            print_notification("Connection to maki failed.")
        main_window.update_divider()

    elif cmd == "disconnect":
        if no_connection():
            return

        connection.disconnect()
        print_notification("Disconnected from maki.")
        main_window.update_divider()

    elif cmd == "shutdown":
        if no_connection():
            return

        connection.sushi.shutdown(config.get("chatting", "quit_message"))
        main_window.update_divider()

    else:
        usage()
        return
Exemple #3
0

import pandas as pd
import connection

path = r'C:\Users\comil\OneDrive\Documents\GitHub' \
    r'\covid19\data\dim\sources.txt'
df = pd.read_csv(
    path,
    sep='\t',
    names=['name','alias','url']
)

cnxn, crsr, engine = connection.connect()
df.to_sql(
    name='dim_sources',
    con=engine,
    if_exists='append',
    index=False
)

connection.disconnect(cnxn, crsr, engine)
# Send query and receive responsec
qbxml_query = 
"""
<?qbxml version="4.0"?>
<QBXML>
   <QBXMLMsgsRq onError="continueOnError">
      <AccountQueryRq>
	<IncludeRetElement>Name</IncludeRetElement>
         <IncludeRetElement>Balance</IncludeRetElement>
      </AccountQueryRq>
   </QBXMLMsgsRq>
</QBXML>
"""
qbxml_response = s.ProcessRequest(t, qbxml_query)

#Disconnect connection
connection.disconnect(s)


# Parse the response by Element Tree 
QBXML=connect.Et.fromstring(qbxml_response)

QBXMLMsgRs=QBXML.find("QBXMLMsgsRs")
AccountRet=QBXMLMsgRs.getiterator("AccountRet")

for a in AccountRet:
    names=a.find('Name').text
    balances=a.find('Balance').text
    print names,"\t|\t",balances

Exemple #5
0
    impexp.sendInventory(inventory, masterSocket)
    print("<waiting to receive Payload form Peer...>")
    payloadStatus = impexp.receivePeerPayload(masterSocket)
    print("<creating Payload for Peer>")
    impexp.createPayload(log, inventory, peerInventoryList)
    print("<sending Payload to Peer>")
    impexp.sendPayload(masterSocket)
    if payloadStatus == 1:
        print("<updating log and Inventory with received payload")
        impexp.handlePayload(log, inventory)
    print("<Your log database has been updated>")
    impexp.cleanUpPayloads()
    print("<Cleaned up payload files>")

if isMaster is True:
    connection.disconnect([masterSocket, slaveSocket])
else:
    connection.disconnect(slaveSocket)
print("<Program terminated>")
"""Deprecated code snipped #1
entriesCount = impexp.file_len("logtextfile.txt") Deprecated
We open a line for reading+writing, pointer is at beginning of file
f = open("logtextfile.txt", "r+")  #Deprecated
for _ in range(1,entriesCount+1,1): #Deprecated
    #readline() reads the entire line and presumably doesn't reset the pointer
    rawEntry = f.readline() #Deprecated
    formattedEntry = impexp.createEntry(rawEntry)  #Deprecated
    try:
        impexp.processEntry(formattedEntry)    #Deprecated
    except ValueError:                         #Deprecated
        print(ValueError)                      #Deprecated
Exemple #6
0
def getMsg(request) :
    sid = request.COOKIES['sessionid']
    uid = connection.get_uid(sid)
    regUser = request.user
    print request.session.items()

    pending_message = ''
    d=''
    if request.method == 'POST' :
        form = PostForm(request.POST)

    else:
        if request.GET.get('getMsg', '') == 'True' :
            msg = repr(request.session.items())
            if msg!='' :
                pending_message = msg
                ##return some xml containing this pending message.. 
                #return connection.XMLize(pending_message,request)

                #Why the return - the pending msg is sent to the user requesting it, and since the client side js will update the page's contents using this new xml message, we do not need to do anything..
                # Below 2 lines for testing purposes using manual GET
                form = PostForm()
                return render_to_response('chat_template.html' , 
{'form':form , 'Conversation':'Stranger says: '+pending_message , 'session':repr(request.COOKIES) ,'user':regUser } )
            
            else : 
## We have no pending messages..May want to return some form of NULL xml?
                pass 

        elif request.GET.get('alive','') == 'True' :
            ##Act on keep-alive signals
            keep_alive(sid)
            # return nothing since we dont want to update page..
            return 

        elif request.GET.get('quit','') == 'True' :
            connection.disconnect(uid)
            return render_to_response('chat_template.html')

        ##Only display the empty form when none of the above..1st time visit etc
        
        else :
            form = PostForm()
            connection.register_user(request)

#Really dont need this. But this is how it also can be done if we do not wish to use the render_to_response method (which uses the template directory by default

#    fp = open ('/Users/prateeksharma/tp/first/alpha/chat_template.html')
#    t = Template(fp.read())
#    fp.close()
        
    if form.is_valid():
        message = form.cleaned_data['message']
        d=Session.objects.all()
        connection.send_message(message , uid)
        message = 'You Said: ' + message

    else: 
        message=''
    
    ##Now comes the matter of pending messages FOR this user...

    return render_to_response('chat_template.html' , 
{'form':form , 'Conversation': message , 'session':repr(request.session.items()), 'user':regUser } )
#for Testing purpose
import connection
ser = connection.connect()
print "-- Acceptes only two argument commend --"
try:
	while True:
		output =[]
		print "NEX "
		input_var = raw_input("Enter Command : ")
		input_var = input_var.split()
		inpt= "NEX" + ('\\x' + input_var[0]).decode('string_escape') +('\\x' + input_var[1]) .decode('string_escape')
		print inpt
		output = ser.write(inpt) 
		print output
except:
	connection.disconnect()