Commits

3k committed fa3c80d

fixed module reloading issue

Comments (0)

Files changed (2)

     help="list available keyboard shortcuts and exit")
 parser.add_argument("-v", "--version", action="version", version="pilpal {0}".format(pp.__version__))
 
+here = os.getcwd()
 args = parser.parse_args()
-input_file = args.input_file
+input_file = os.path.join(here, args.input_file)
 image_file = args.output_file if args.output_file is not None else input_file.replace(".py", ".png")
 
 if not args.silent:
     print("pilpal {0}".format(pp.__version__))
 
 try:
-    here = os.getcwd()
     sys.path.append(here)
     image_file = os.path.join(here, image_file)
     if not os.path.exists(input_file):
 import traceback
 import time
 from datetime import datetime
-from importlib import import_module
+from imp import load_source
 from threading import Thread
 from Queue import Queue, Empty
 import Tkinter
         self.root = tk
         self.src = src
         self.output_file = output_file
-        self.modname = src.replace(".py", "")
+        self.modname = os.path.basename(src.replace(".py", ""))
         self.silent = silent
         self.last_src_mtime = 0
         self.old_label_img = None
         return img
 
     def reload(self):
-        reload(import_module(self.modname))
+        load_source(self.modname, self.src)
         return self.display_file(self.output_file)
 
     def source_modified(self):
         return True
 
     def run(self):
-        self.log("using source: {0}".format(self.src, self.LOG_NORMAL))
+        self.log("using source: {0} ({1})".format(self.src, self.modname), self.LOG_NORMAL)
         self.running = True
         waiting = False
         while self.running: