Guest User

Untitled

a guest
Nov 23rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. @route('/')
  2. def index():
  3. return template('index')
  4.  
  5. @route('/', method='POST')
  6. def upload():
  7. incfile = request.files.get('uploadinc')
  8. datfile = request.files.get('uploadhex')
  9.  
  10. macro, ext1 = os.path.splitext(incfile.filename)
  11. data, ext2 = os.path.splitext(datfile.filename)
  12. if ext1 not in ('.txt'):
  13. return 'File extension not allowed.'
  14. if ext2 not in ('.txt'):
  15. return 'File extension not allowed.'
  16. incfile.filename = 'macro.txt'
  17. datfile.filename = 'data.txt'
  18.  
  19. curr_dir = os.getcwd()
  20. print(curr_dir)
  21. temp_dir = os.path.join(curr_dir, r'temp01')
  22. if os.path.exists(temp_dir):
  23. shutil.rmtree(temp_dir)
  24. os.makedirs(temp_dir)
  25.  
  26. incfile.save(temp_dir)
  27. datfile.save(temp_dir)
  28. clean_up(temp_dir) // gives error
  29.  
  30. @route('/')
  31. def clean_up(): // gives error
  32.  
  33. import os, sys, re, binascii
  34.  
  35. def clean_up():
  36.  
  37. if os.path.exists("dataparse.txt"):
  38. os.remove("dataparse.txt")
  39. else:
  40. print("Creating new files...")
  41.  
  42. if os.path.exists("out3.txt"):
  43. os.remove("out3.txt")
  44. else:
  45. print("Creating new files...")
  46.  
  47. def parse_hexdump():
  48. a = open("data.txt","r")
  49. b = open("dataparse.txt","a")
  50. w = open("out3.txt","a")
  51. str = a.readline()
  52. w.write(str)
  53. for line in a:
  54. if line.startswith('MD') or line.startswith('END OF DISPLAY'):
  55. continue
  56. else:
  57. strline = line[5:40:] # Slice lines from 5-40 to another file
  58. b.write(strline+'n')
  59. b.close()
  60. w.close()
Add Comment
Please, Sign In to add comment