def generate_tests(modules, force, template): try: project = Project.from_directory(find_project_directory(modules[0])) inspect_project(project) add_tests_to_project(project, modules, template, force) project.save() except PythoscopeDirectoryMissing: fail("Can't find .pythoscope/ directory for this project. " "Initialize the project with the '--init' option first.") except ModuleNeedsAnalysis as err: if err.out_of_sync: fail("Tried to generate tests for test module located at %r, " "but it has been modified during this run. Please try " "running pythoscope again." % err.path) else: fail("Tried to generate tests for test module located at %r, " "but it was created during this run. Please try running " "pythoscope again." % err.path) except ModuleNotFound as err: if os.path.exists(err.module): fail("Couldn't find information on module %r. This shouldn't " "happen, please file a bug report at %s." % (err.module, BUGTRACKER_URL)) else: fail("File doesn't exist: %s." % err.module) except ModuleSaveError as err: fail("Couldn't save module %r: %s." % (err.module, err.reason)) except UnknownTemplate as err: fail("Couldn't find template named %r. Available templates are " "'nose' and 'unittest'." % err.template)
def start(): global project, tracer, inspector try: project = Project.from_directory(find_project_directory(os.getcwd())) execution = Execution(project) inspector = Inspector(execution) tracer = Tracer(inspector) tracer.btracer.setup() sys.settrace(tracer.tracer) except PythoscopeDirectoryMissing: print "Can't find .pythoscope/ directory for this project. " \ "Initialize the project with the '--init' option first. " \ "Pythoscope tracing disabled for this run."
def init_project(path, skip_inspection=False): pythoscope_path = get_pythoscope_path(path) try: log.debug("Initializing .pythoscope directory: %s" % (os.path.abspath(pythoscope_path))) os.makedirs(pythoscope_path) os.makedirs(get_points_of_entry_path(path)) os.makedirs(get_code_trees_path(path)) except OSError as err: fail("Couldn't initialize Pythoscope directory: %s." % err.strerror) project = Project.from_directory(path) if not skip_inspection: log.debug("Performing initial static inspection of the project source code.") inspect_project_statically(project) project.save()
def generate_tests(modules, force, template): try: project = Project.from_directory(find_project_directory(modules[0])) inspect_project(project) add_tests_to_project(project, modules, template, force) project.save() except PythoscopeDirectoryMissing: fail("Can't find .pythoscope/ directory for this project. " "Initialize the project with the '--init' option first.") except ModuleNeedsAnalysis, err: if err.out_of_sync: fail("Tried to generate tests for test module located at %r, " "but it has been modified during this run. Please try " "running pythoscope again." % err.path) else: fail("Tried to generate tests for test module located at %r, " "but it was created during this run. Please try running " "pythoscope again." % err.path)
def incoming_add(self, data, text): cmd = shlex.split(text)[1:] parser = ArgumentParser(prog="add", description='Add a new project') parser.add_argument("url", help="Git url of the repository") parser.add_argument( "--keystore", help="Path to the keystore file relative to the project root", default="") parser.add_argument("--keystore_pwd", help="Keystore password", default="") parser.add_argument("--key", help="Keystore key", default="") parser.add_argument("--key_pwd", help="Keystore key password", default="") parser.add_argument("--name", help="Name of the project (optional)", default="") try: args = parser.parse_args(cmd) args.url = re.sub(r"<mailto:(.+)\|(.+)>", lambda m: m.group(1), args.url) if self.store.is_url_exists(args.url): raise Exception("Project with url %s already exists" % args.url) project = Project(args.url, args.keystore, args.keystore_pwd, args.key, args.key_pwd, args.name) self.store.add_project(project) self.send_msg( data, """Project added with parameters: *Url:* %s *Keystore file path:* %s *Keystore password:* %s *Key:* %s *Key password:* %s *Name:* %s """ % (project.url, project.keystore_filename, project.keystore_pwd, project.key, project.key_pwd, project.name)) except Exception as ex: self.send_msg(data, str(ex))
return find_project_directory(os.path.join(path, os.path.pardir)) def init_project(path, skip_inspection=False): pythoscope_path = get_pythoscope_path(path) try: log.debug("Initializing .pythoscope directory: %s" % (os.path.abspath(pythoscope_path))) os.makedirs(pythoscope_path) os.makedirs(get_points_of_entry_path(path)) os.makedirs(get_code_trees_path(path)) except OSError, err: fail("Couldn't initialize Pythoscope directory: %s." % err.strerror) project = Project.from_directory(path) if not skip_inspection: log.debug( "Performing initial static inspection of the project source code.") inspect_project_statically(project) project.save() def generate_tests(modules, force, template): try: project = Project.from_directory(find_project_directory(modules[0])) inspect_project(project) add_tests_to_project(project, modules, template, force) project.save() except PythoscopeDirectoryMissing: fail("Can't find .pythoscope/ directory for this project. "
return path else: return find_project_directory(os.path.join(path, os.path.pardir)) def init_project(path, skip_inspection=False): pythoscope_path = get_pythoscope_path(path) try: log.debug("Initializing .pythoscope directory: %s" % (os.path.abspath(pythoscope_path))) os.makedirs(pythoscope_path) os.makedirs(get_points_of_entry_path(path)) os.makedirs(get_code_trees_path(path)) except OSError, err: fail("Couldn't initialize Pythoscope directory: %s." % err.strerror) project = Project.from_directory(path) if not skip_inspection: log.debug("Performing initial static inspection of the project source code.") inspect_project_statically(project) project.save() def generate_tests(modules, force, template): try: project = Project.from_directory(find_project_directory(modules[0])) inspect_project(project) add_tests_to_project(project, modules, template, force) project.save() except PythoscopeDirectoryMissing: fail("Can't find .pythoscope/ directory for this project. " "Initialize the project with the '--init' option first.") except ModuleNeedsAnalysis, err: