@@ -132,7 +132,7 @@ def _setContentDispositionAndSend(file_path, extension, content_type):
132132 if self .db .filemap .get_file (request .args ["hash" ][0 ]) is not None :
133133 image_path = self .db .filemap .get_file (request .args ["hash" ][0 ])
134134 else :
135- image_path = DATA_FOLDER + "cache/" + request .args ["hash" ][0 ]
135+ image_path = os . path . join ( DATA_FOLDER , "cache" , request .args ["hash" ][0 ])
136136 if not os .path .exists (image_path ) and "guid" in request .args :
137137 node = None
138138 for connection in self .protocol .values ():
@@ -726,7 +726,8 @@ def respond(success):
726726 else :
727727 request .write (json .dumps ({"success" : False , "reason" : success }))
728728 request .finish ()
729- file_path = DATA_FOLDER + "store/contracts/in progress/" + request .args ["id" ][0 ] + ".json"
729+ file_name = request .args ["id" ][0 ] + ".json"
730+ file_path = os .path .join (DATA_FOLDER , "store" , "contracts" , "in progress" , file_name )
730731 with open (file_path , 'r' ) as filename :
731732 order = json .load (filename , object_pairs_hook = OrderedDict )
732733 c = Contract (self .db , contract = order , testnet = self .protocol .testnet )
@@ -762,23 +763,37 @@ def upload_image(self, request):
762763 for image in request .args ["image" ]:
763764 img = image .decode ('base64' )
764765 hash_value = digest (img ).encode ("hex" )
766+ < << << << HEAD
765767 with open (DATA_FOLDER + "store/media/" + hash_value , 'wb' ) as outfile :
766768 outfile .write (img )
767769 self .db .filemap .insert (hash_value , "store/media/" + hash_value )
770+ == == == =
771+ with open (os .path .join (DATA_FOLDER , "store" , "media" , hash_value ), 'wb' ) as outfile :
772+ outfile .write (img )
773+ self .db .filemap .insert (hash_value , os .path .join (DATA_FOLDER , "store" , "media" , hash_value ))
774+ > >> >> >> dbb6784f4627c543b4611e825e2729c60f46cb1b
768775 ret .append (hash_value )
769776 elif "avatar" in request .args :
770777 avi = request .args ["avatar" ][0 ].decode ("base64" )
771778 hash_value = digest (avi ).encode ("hex" )
772- with open (DATA_FOLDER + "store/ avatar" , 'wb' ) as outfile :
779+ with open (os . path . join ( DATA_FOLDER , "store" , " avatar") , 'wb' ) as outfile :
773780 outfile .write (avi )
781+ << << << < HEAD
774782 self .db .filemap .insert (hash_value , "store/avatar" )
783+ == == == =
784+ self .db .filemap .insert (hash_value , os .path .join (DATA_FOLDER , "store" , "avatar" ))
785+ >> >> >> > dbb6784f4627c543b4611e825e2729c60f46cb1b
775786 ret .append (hash_value )
776787 elif "header" in request .args :
777788 hdr = request .args ["header" ][0 ].decode ("base64" )
778789 hash_value = digest (hdr ).encode ("hex" )
779- with open (DATA_FOLDER + "store/ header" , 'wb' ) as outfile :
790+ with open (os . path . join ( DATA_FOLDER , "store" , " header") , 'wb' ) as outfile :
780791 outfile .write (hdr )
792+ << << << < HEAD
781793 self .db .filemap .insert (hash_value , "store/header" )
794+ == == == =
795+ self .db .filemap .insert (hash_value , os .path .join (DATA_FOLDER , "store" , "header" ))
796+ >> >> >> > dbb6784f4627c543b4611e825e2729c60f46cb1b
782797 ret .append (hash_value )
783798 request .write (json .dumps ({"success" : True , "image_hashes" : ret }, indent = 4 ))
784799 request .finish ()
@@ -798,9 +813,13 @@ def respond(success):
798813 else :
799814 request .write (json .dumps ({"success" : False , "reason" : success }))
800815 request .finish ()
816+ < << << << HEAD
801817 file_path = DATA_FOLDER + "purchases/in progress/" + request .args ["id" ][0 ] + ".json"
802818 if not os .path .exists (file_path ):
803819 file_path = DATA_FOLDER + "purchases/trade receipts/" + request .args ["id" ][0 ] + ".json"
820+ == == == =
821+ file_path = os .path .join (DATA_FOLDER , "purchases" , "in progress" , request .args ["id" ][0 ] + ".json" )
822+ > >> >> >> dbb6784f4627c543b4611e825e2729c60f46cb1b
804823 with open (file_path , 'r' ) as filename :
805824 order = json .load (filename , object_pairs_hook = OrderedDict )
806825 c = Contract (self .db , contract = order , testnet = self .protocol .testnet )
@@ -1152,27 +1171,27 @@ def get_order(self, request):
11521171 #TODO: if this is either a funded direct payment sale or complete moderated sale but
11531172 #TODO: the payout tx has not hit the blockchain, rebroadcast.
11541173
1155- if os .path .exists (DATA_FOLDER + "purchases/unfunded/" + request .args ["order_id" ][0 ] + ".json" ):
1156- file_path = DATA_FOLDER + "purchases/unfunded/" + request .args ["order_id" ][0 ] + ".json"
1174+ filename = request .args ["order_id" ][0 ] + ".json"
1175+ if os .path .exists (os .path .join (DATA_FOLDER , "purchases" , "unfunded" , filename )):
1176+ file_path = os .path .join (DATA_FOLDER , "purchases" , "unfunded" , filename )
11571177 status = self .db .purchases .get_status (request .args ["order_id" ][0 ])
1158- elif os .path .exists (DATA_FOLDER + "purchases/in progress/" + request . args [ "order_id" ][ 0 ] + ".json" ):
1159- file_path = DATA_FOLDER + "purchases/in progress/" + request . args [ "order_id" ][ 0 ] + ".json"
1178+ elif os .path .exists (os . path . join ( DATA_FOLDER , "purchases" , "in progress" , filename ) ):
1179+ file_path = os . path . join ( DATA_FOLDER , "purchases" , "in progress" , filename )
11601180 status = self .db .purchases .get_status (request .args ["order_id" ][0 ])
1161- elif os .path .exists (DATA_FOLDER + "purchases/trade receipts/" + request . args [ "order_id" ][ 0 ] + ".json" ):
1162- file_path = DATA_FOLDER + "purchases/trade receipts/" + request . args [ "order_id" ][ 0 ] + ".json"
1181+ elif os .path .exists (os . path . join ( DATA_FOLDER , "purchases" , "trade receipts" , filename ) ):
1182+ file_path = os . path . join ( DATA_FOLDER , "purchases" , "trade receipts" , filename )
11631183 status = self .db .purchases .get_status (request .args ["order_id" ][0 ])
1164- elif os .path .exists (DATA_FOLDER + "store/contracts/unfunded/" + request . args [ "order_id" ][ 0 ] + ".json" ):
1165- file_path = DATA_FOLDER + "store/contracts/unfunded/" + request . args [ "order_id" ][ 0 ] + ".json"
1184+ elif os .path .exists (os . path . join ( DATA_FOLDER , "store" , "contracts" , "unfunded" , filename ) ):
1185+ file_path = os . path . join ( DATA_FOLDER , "store" , "contracts" , "unfunded" , filename )
11661186 status = self .db .sales .get_status (request .args ["order_id" ][0 ])
1167- elif os .path .exists (DATA_FOLDER + "store/contracts/in progress/" + request . args [ "order_id" ][ 0 ] + ".json" ):
1168- file_path = DATA_FOLDER + "store/contracts/in progress/" + request . args [ "order_id" ][ 0 ] + ".json"
1187+ elif os .path .exists (os . path . join ( DATA_FOLDER , "store" , "contracts" , "in progress" , filename ) ):
1188+ file_path = os . path . join ( DATA_FOLDER , "store" , "contracts" , "in progress" , filename )
11691189 status = self .db .sales .get_status (request .args ["order_id" ][0 ])
1170- elif os .path .exists (DATA_FOLDER +
1171- "store/contracts/trade receipts/" + request .args ["order_id" ][0 ] + ".json" ):
1172- file_path = DATA_FOLDER + "store/contracts/trade receipts/" + request .args ["order_id" ][0 ] + ".json"
1190+ elif os .path .exists (os .path .join (DATA_FOLDER , "store" , "contracts" , "trade receipts" , filename )):
1191+ file_path = os .path .join (DATA_FOLDER , "store" , "contracts" , "trade receipts" , filename )
11731192 status = self .db .sales .get_status (request .args ["order_id" ][0 ])
1174- elif os .path .exists (DATA_FOLDER + "cases/" + request . args [ "order_id" ][ 0 ] + ".json" ):
1175- file_path = DATA_FOLDER + "cases/" + request . args [ "order_id" ][ 0 ] + ".json"
1193+ elif os .path .exists (os . path . join ( DATA_FOLDER , "cases" , filename ) ):
1194+ file_path = os . path . join ( DATA_FOLDER , "cases" , filename )
11761195 status = 4
11771196 else :
11781197 request .write (json .dumps ({}, indent = 4 ))
0 commit comments