I got stuck on an error which I didn't have when I've done something similar in python 2.
Here is the code:
def computeSha(self,reqFile):
filesize_bytes = os.path.getsize(reqFile)
s = sha1()
s.update(("blob %u\0" % filesize_bytes).encode('utf-8'))
with open(reqFile, 'rb') as f:
s.update(f.read())
s = s.hexdigest()
print ("here is the sha: " + s)
return s
def _sendSha(self, component_id):
component_path = db_connector.get_design_path(component_id)
sha = self.computeSha(component_path)
self.connection.send(self._adjustLength(len(sha)))
self.connection.sendall(data)
The error appears here: self.connection.send(self._adjustLength(len(sha)))
Here is the code for adjustLength:
def _adjustLength(self, length):
#max size is 8 bytes long
length = str(length)
if DEBUG:
print("_adjustLength before:" + length)
while len(length) < 8:
length = "0"+length
length = length+"\n"
if DEBUG:
print("_adjustLength after:" + length)
return length
self.connection?self._adjustLength().self.connection.send(self._adjustLength(len(sha)))withself.connection.send(self._adjustLength(len(sha)).encode()).