Rev467, requirements.txt accept newer dependecies, Boost dbschema.json, Move getDirname getFilename to helper, Verify optional files, Includes not allowed in user files, Optional files rules, Peer hashfield functions, Test optional files signing, Test file info, Test verify file, Test helpers

This commit is contained in:
HelloZeroNet 2015-10-01 01:35:13 +02:00
parent a7d8d488da
commit 9d7d4f1552
22 changed files with 486 additions and 220 deletions

View file

@ -1,6 +1,7 @@
import os
import socket
import struct
import re
def atomicWrite(dest, content, mode="w"):
@ -16,10 +17,27 @@ def shellquote(*args):
else:
return tuple(['"%s"' % arg.replace('"', "") for arg in args])
# ip, port to packed 6byte format
def packAddress(ip, port):
return socket.inet_aton(ip) + struct.pack("H", port)
# From 6byte format to ip, port
def unpackAddress(packed):
return socket.inet_ntoa(packed[0:4]), struct.unpack_from("H", packed, 4)[0]
return socket.inet_ntoa(packed[0:4]), struct.unpack_from("H", packed, 4)[0]
# Get dir from file
# Return: data/site/content.json -> data/site
def getDirname(path):
file_dir = re.sub("[^/]*?$", "", path).rstrip("/")
if file_dir:
file_dir += "/" # Add / at end if its not the root
return file_dir
# Get dir from file
# Return: data/site/content.json -> content.json
def getFilename(path):
return re.sub("^.*/", "", path)