I'm trying to send the contents of a file over to the client 1 line at a time so that the client (written in Objective-C) can process each line individually. However the log of the client shows that the data being send over from the server is all coming through as 1 line and is apparently too large so the it cuts off mid way through one line causing the client to crash because of the unexpected syntax.
Is there something i'm doing on the server(written in python with twisted) that is causing the lines to not be sent separately?
Here is the particular code in the server that is holding me up at the moment.
def sendLine(self, line):
self.transport.write(line + '\r\n')
def updateShiftList(self):
#open the datesRequested file for the appropriate store and load the dates into a list
fob = open('stores/'+self.storeName+'/requests/datesRequested','r')
DATES_REQUESTED = fob.read()
datesRequested = DATES_REQUESTED.split('\n')
#open each date file that is listed in datesRequested
for date in datesRequested:
if os.path.isfile('stores/'+self.storeName+'/requests/' + date):
fob2 = open('stores/'+self.storeName+'/requests/' + date,'r')
#load the file into memory and split the individual requests up
THE_REQUESTS = fob2.read()
thedaysRequests = THE_REQUESTS.split('\n')
for oneRequest in thedaysRequests:
if len(oneRequest) > 4:
print "*)[*_-b4.New_REQUEST:"+oneRequest
self.sendLine('*)[*_-b4.New_REQUEST:'+oneRequest)
fob2.close()
fob.close()
So frustrating and i'm sure it's something easy. Thanks.