Example #1
0
 def __init__( self, eprimerOptions ):
         
     self.programName = "EPrimer3"
     self.options = eprimerOptions
     
     primer3corePath = utils.search_file( "primer3_core" )
     if primer3corePath is None:
         raise utils.ProgramNotFoundException( "primer3_core", "Please ensure that the primer3 package is installed on your system. It can be obtained from http://primer3.sourceforge.net/" )
     
     eprimerPath = utils.search_file( "eprimer3" )
     if eprimerPath is None:
         raise utils.ProgramNotFoundException( 'eprimer3', "Please ensure that the EMBOSS package is installed and configured on your system." )
     
     self.primer3core = primer3corePath
     self.eprimer3 = eprimerPath
Example #2
0
    def deployRepoAttempt(self, attempt, deployPath):
        utils.vagrant_pip_clear()

        setup_files = utils.search_file(deployPath, 'setup.py')
        LOG.info('setup.py: ' + str(setup_files))
        if len(setup_files):
            return ATTEMPT_STATUS_NOT_AN_APPLICATION

        setting_files = utils.search_file(deployPath, 'settings.py')
        LOG.info('settings.py: ' + str(setting_files))
        if not len(setting_files):
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
                
        manage_files = utils.search_file(deployPath, 'manage.py')
        LOG.info('manage.py: ' + str(manage_files))
        if not len(manage_files):
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES

        self.requirement_files = utils.search_file(deployPath, 'requirements.txt')
        LOG.info('REQUIREMENTS: ' + str(self.requirement_files))
        
        manage_paths = [os.path.dirname(manage_file) for manage_file in manage_files]
        LOG.info("MANAGE_PATHS: " + str(manage_paths))
        setting_paths = [os.path.dirname(os.path.dirname(setting_file)) for setting_file in setting_files]
        LOG.info("setting_paths: " + str(setting_paths))
        base_dirs = set.intersection(set(manage_paths), set(setting_paths))
        if not base_dirs:
            LOG.error('can not find base directory')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = next(iter(base_dirs))
        LOG.info('BASE_DIR: ' + base_dir)
        manage_file = next(name for name in manage_files if name.startswith(base_dir))
        setting_file = next(name for name in setting_files if name.startswith(base_dir))

        # Database
        attempt.database = self.getDatabase(setting_file)
        LOG.info('DATABASE: ' + attempt.database.name)
        
        # Base Dir
        attempt.base_dir = base_dir.split('/', 1)[1]
        LOG.info('BASE_DIR: ' + attempt.base_dir)
        
        # Settings Dir
        attempt.setting_dir = os.path.basename(os.path.dirname(setting_file))
        LOG.info('SETTING_DIR: ' + attempt.setting_dir)
        
        # Try to deploy!
        return self.tryDeploy(attempt, manage_file, setting_file)
Example #3
0
def compile():
    if settings["download_missing_files"]:
        version = repository.Version.get_version_file()
        repo.compare_tree(version.branch) if version.commit_hash is None else repo.compare_tree(version.commit_hash)
    locales.adv_print("BUILDING")
    if not os.path.exists("gradlew.bat"):
        with open("gradlew.bat", "w") as f:
            f.write(requests.get("https://raw.githubusercontent.com/michel-kraemer/gradle-download-task/master/gradlew.bat").text)
    process = subprocess.Popen(["gradlew.bat", "RatPoison"])
    process.communicate()
    return_code = process.returncode
    utils.kill_jdk()
    if return_code == 0:
        delete_libs_folder()
        bat_file = utils.get_bat_name()
        for path in utils.search_file("java.exe"):
            if utils.verify_path(path):
                java_exe = str(path)
                with open(bat_file, "r") as rFile:
                    prev_lines = rFile.readlines()
                prev_lines[4] = prev_lines[4].replace("java", f"\"{java_exe}\"", 1)
                with open(bat_file, "w") as wFile:
                    wFile.writelines(prev_lines)
                break
        if locales.adv_input("RANDOMIZE_FILE_NAMES_INPUT") in locales.yes:
            randomize_file_names()
        replace_bat_path()
    else:
        if locales.adv_input("RETRY_BUILD_INPUT"):
            settings["skip_jdk_checks"] = False
            settings["force_install_jdk"] = True
            jdk_tools.download_jdk()
            compile()
Example #4
0
    def __init__( self ):    

        self.programName = "PrimerSearch"
        primerSearchPath = utils.search_file( "primersearch" )
        if primerSearchPath is None:
            raise utils.ProgramNotFoundException( "primersearch", "Please ensure that the EMBOSS package is installed on your system." )
    
        self.primerSearch = primerSearchPath
Example #5
0
    def deploy_repo_attempt(self, deploy_path):
        LOG.info(utils.configure_env(self.base_path))

        manage_files = utils.search_file(deploy_path, 'manage.py')
        if not manage_files:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        manage_paths = [os.path.dirname(manage_file) for manage_file in manage_files]
        base_dir = next(name for name in manage_paths if 'lib/python2.7/site-packages/' not in name)
        manage_path = next(name for name in manage_paths if name.startswith(base_dir))
        LOG.info('manage.py path: {}'.format(manage_path))

        with open(os.path.join(manage_path, 'manage.py'), 'r') as manage_file:
            s = re.search('os.environ.setdefault\("DJANGO_SETTINGS_MODULE", "(.*)"\)', manage_file.read())
            if s:
                setting_path = s.group(1)
            else:
                return ATTEMPT_STATUS_MISSING_REQUIRED_FILES

        setting_path = setting_path.replace('.', '/')
        if os.path.isdir(os.path.join(manage_path, setting_path)):
            setting_path = os.path.join(manage_path, setting_path)
            for setting_file in sorted(os.listdir(setting_path)):
                if os.path.isfile(os.path.join(setting_path, setting_file)):
                    setting_path = os.path.join(setting_path, setting_file)
                    break
            self.setting_path = setting_path
        elif os.path.isfile(os.path.join(manage_path, setting_path + '.py')):
            setting_path = os.path.join(manage_path, setting_path + '.py')
            self.setting_path = setting_path
        else:
            for candidate_setting_files in utils.search_file_regex(deploy_path, '^settings.*\.py$'):
                setting_path = os.path.join(manage_path, setting_path + '.py')
                utils.copy_file(candidate_setting_files, setting_path)
                self.setting_path = setting_path
                break
        if self.setting_path == None:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        LOG.info('setting.py path: {}'.format(setting_path))

        requirement_files = utils.search_file(deploy_path, 'requirements.txt')
        if requirement_files:
            LOG.info('requirements.txt path: {}'.format(requirement_files))
        
        return self.try_deploy(manage_path, requirement_files)
Example #6
0
    def deploy_repo_attempt(self, deploy_path):
        LOG.info(utils.configure_env(self.base_path))

        manage_files = utils.search_file(deploy_path, 'manage.py')
        if not manage_files:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        manage_paths = [os.path.dirname(manage_file) for manage_file in manage_files]
        base_dir = next(name for name in manage_paths if 'lib/python2.7/site-packages/' not in name)
        manage_path = next(name for name in manage_paths if name.startswith(base_dir))
        LOG.info('manage.py path: {}'.format(manage_path))

        with open(os.path.join(manage_path, 'manage.py'), 'r') as manage_file:
            s = re.search('os.environ.setdefault\("DJANGO_SETTINGS_MODULE", "(.*)"\)', manage_file.read())
            if s:
                setting_path = s.group(1)
            else:
                return ATTEMPT_STATUS_MISSING_REQUIRED_FILES

        setting_path = setting_path.replace('.', '/')
        if os.path.isdir(os.path.join(manage_path, setting_path)):
            setting_path = os.path.join(manage_path, setting_path)
            for setting_file in sorted(os.listdir(setting_path)):
                if os.path.isfile(os.path.join(setting_path, setting_file)):
                    setting_path = os.path.join(setting_path, setting_file)
                    break
            self.setting_path = setting_path
        elif os.path.isfile(os.path.join(manage_path, setting_path + '.py')):
            setting_path = os.path.join(manage_path, setting_path + '.py')
            self.setting_path = setting_path
        else:
            for candidate_setting_files in utils.search_file_regex(deploy_path, '^settings.*\.py$'):
                setting_path = os.path.join(manage_path, setting_path + '.py')
                utils.copy_file(candidate_setting_files, setting_path)
                self.setting_path = setting_path
                break
        if self.setting_path == None:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        LOG.info('setting.py path: {}'.format(setting_path))

        requirement_files = utils.search_file(deploy_path, 'requirements.txt')
        if requirement_files:
            LOG.info('requirements.txt path: {}'.format(requirement_files))
        
        return self.try_deploy(manage_path, requirement_files)
Example #7
0
    def __init__( self ):
        #if we can't find the nucemer binary, throw
        nucmerPath = utils.search_file( 'nucmer' )
        ProgramBase.__init__( self )
        if nucmerPath is None:
            raise utils.ProgramNotFoundException( 'nucmer', "Please ensure that the MUMmer package is installed and configured on your system." )
        
        self.nucmer = nucmerPath

        self.programName = "nucmer"
        self.outputExtension = ".coords"
Example #8
0
    def deploy_repo_attempt(self, deploy_path):
        rake_files = utils.search_file(deploy_path, 'Rakefile')
        if not rake_files:
            LOG.error('No rakefile found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        rakefile_paths = [
            os.path.dirname(rake_file) for rake_file in rake_files
        ]

        gem_files = utils.search_file(deploy_path, 'Gemfile')
        if not gem_files:
            LOG.error('No gemfile found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        gemfile_paths = [os.path.dirname(gem_file) for gem_file in gem_files]

        base_dirs = sorted(
            set.intersection(set(rakefile_paths), set(gemfile_paths)))
        if not base_dirs:
            LOG.error('Can not find base directory!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = next(iter(base_dirs))

        config_files = utils.search_file_regex(
            os.path.join(base_dir, 'config'), '.*yml.*')
        for config_file in config_files:
            if '.example' in config_file:
                new_config_file = config_file.replace('.example', '')
                utils.copy_file(config_file, new_config_file)
            elif '/example' in config_file:
                new_config_file = config_file.replace('/example', '')
                utils.copy_file(config_file, new_config_file)
            elif '-sample' in config_file:
                new_config_file = config_file.replace('-sample', '')
                utils.copy_file(config_file, new_config_file)
            elif '.tmpl' in config_file:
                new_config_file = config_file.replace('.tmpl', '')
                utils.copy_file(config_file, new_config_file)

        self.setting_path = base_dir

        return self.try_deploy(base_dir)
Example #9
0
 def get_urls(self):
     setting_files = utils.search_file(BaseDeployer.TMP_DEPLOY_PATH, 'settings.py')[0]
     dirname = os.path.dirname(setting_files)
     sys.path.append(dirname)
     proj_name = os.path.basename(setting_files)
     command = "python " + utils.to_vm_path('get_urls.py') + ' ' + utils.to_vm_path(dirname) + ' ' + proj_name
     out = utils.vagrant_run_command(command).strip()
     if not out:
         urls = []
     else:
         urls = out.splitlines()
     return urls
Example #10
0
    def deploy_repo_attempt(self, deploy_path):
        install_phps = utils.search_file(deploy_path, 'install.php')
        if len(install_phps) == 0:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = sorted([os.path.dirname(install_php) for install_php in install_phps])[0]

        self.setting_path = base_dir

        return self.try_deploy(base_dir)
    ## DEF
    
## CLASS
Example #11
0
    def deploy_repo_attempt(self, deploy_path):
        rake_files = utils.search_file(deploy_path, 'Rakefile')
        if not rake_files:
            LOG.error('No rakefile found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        rakefile_paths = [os.path.dirname(rake_file) for rake_file in rake_files]

        gem_files = utils.search_file(deploy_path, 'Gemfile')
        if not gem_files:
            LOG.error('No gemfile found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        gemfile_paths = [os.path.dirname(gem_file) for gem_file in gem_files]

        base_dirs = sorted(set.intersection(set(rakefile_paths), set(gemfile_paths)))
        if not base_dirs:
            LOG.error('Can not find base directory!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = next(iter(base_dirs))

        config_files = utils.search_file_regex(os.path.join(base_dir, 'config'), '.*yml.*')
        for config_file in config_files:
            if '.example' in config_file:
                new_config_file = config_file.replace('.example', '')
                utils.copy_file(config_file, new_config_file)
            elif '/example' in config_file:
                new_config_file = config_file.replace('/example', '')
                utils.copy_file(config_file, new_config_file)
            elif '-sample' in config_file:
                new_config_file = config_file.replace('-sample', '')
                utils.copy_file(config_file, new_config_file)
            elif '.tmpl' in config_file:
                new_config_file = config_file.replace('.tmpl', '')
                utils.copy_file(config_file, new_config_file)

        self.setting_path = base_dir

        return self.try_deploy(base_dir)
Example #12
0
    def deploy_repo_attempt(self, deploy_path):
        install_phps = utils.search_file(deploy_path, 'install.php')
        if len(install_phps) == 0:
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = sorted(
            [os.path.dirname(install_php) for install_php in install_phps])[0]

        self.setting_path = base_dir

        return self.try_deploy(base_dir)

    ## DEF


## CLASS
Example #13
0
    def deploy_repo_attempt(self, deploy_path):
        if self.database.name != 'MySQL':
            return ATTEMPT_STATUS_DATABASE_ERROR

        grailsw_files = utils.search_file(deploy_path, 'grailsw')
        if not grailsw_files:
            LOG.error('No grailsw found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = sorted([
            os.path.dirname(grailsw_file) for grailsw_file in grailsw_files
        ])[0]

        self.setting_path = base_dir

        return self.try_deploy(base_dir)

    ## DEF


## CLASS
Example #14
0
def compile():
    if settings["download_missing_files"]:
        version = repository.Version.get_version_file()
        repo.compare_tree(version.branch) if version.commit_hash is None else repo.compare_tree(version.commit_hash)
    locales.adv_print("BUILDING")
    subprocess.check_call(["gradlew.bat", "RatPoison"])
    delete_libs_folder()
    utils.kill_jdk()
    bat_file = utils.get_bat_name()
    for path in utils.search_file("java.exe"):
        if utils.verify_path(str(path)):
            java_exe = str(path)
            with open(bat_file, "r") as rFile:
                prev_lines = rFile.readlines()
            prev_lines[4] = prev_lines[4].replace("java", f"\"{java_exe}\"", 1)
            with open(bat_file, "w") as wFile:
                wFile.writelines(prev_lines)
            break
    if locales.adv_input("RANDOMIZE_FILE_NAMES_INPUT") in locales.yes:
        randomize_file_names()
    replace_bat_path()
Example #15
0
    def deploy_repo_attempt(self, deploy_path):
        package_jsons = utils.search_file(deploy_path, 'package.json')
        if not package_jsons:
            LOG.error('No package.json found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        base_dir = sorted([os.path.dirname(package_json) for package_json in package_jsons])[0]

        for main_filename in ['server.js', 'app.js', 'main.js']:
            if utils.search_file_norecur(base_dir, main_filename):
                self.main_filename = main_filename
                break
        if self.main_filename == None:
            LOG.error('No main file found!')
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES

        self.setting_path = base_dir

        return self.try_deploy(base_dir)
    ## DEF
    
## CLASS
Example #16
0
from utils import search_file
import cv2
import numpy as np
from utils import COLOR_DICT
from utils import dense_crf
from utils import intersectionAndUnion
from PIL import Image
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
# 是否使用cuda
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
num_classes = 2
num_channels = 3
batch_size = 4
size = (256, 256)
root = "data/membrane/test"
img_file = search_file(root, [".png"])
# print(img_file)
if __name__ == "__main__":
    model = U_Net(num_channels, num_classes).to(device)
    model.load_state_dict(torch.load('UNet_weights_bilinear_weight.pth'))
    model.eval()
    with torch.no_grad():
        for i in range(1):
            print(img_file[i])
            input = cv2.imread(img_file[i], cv2.IMREAD_COLOR)
            input = cv2.resize(input, size)
            original_img = input
            print(
                os.path.join(
                    "data/membrane/result1",
                    os.path.splitext(os.path.basename(img_file[i]))[0] +
Example #17
0
    def deploy_repo_attempt(self, deploy_path):
        LOG.info(utils.configure_env(self.base_path))

        self.clear_database()

        if self.repo.setup_scripts != None:
            project_path = utils.search_dir(deploy_path, self.repo.repo_name())
            LOG.info("Project Path: {}".format(project_path))

            LOG.info("Setup Scripts: {} && {} && {} && {}".format(
                utils.to_env(self.base_path),
                "unset DJANGO_SETTINGS_MODULE",
                "cd {}".format(project_path),
                self.repo.setup_scripts))
            code, stdout, stderr = utils.run_command("{} && {} && {} && {}".format(
                utils.to_env(self.base_path),
                "unset DJANGO_SETTINGS_MODULE",
                "cd {}".format(project_path),
                self.repo.setup_scripts))

            LOG.info("Setup Return Code: {}".format(code))
            LOG.debug("Setup Return STDOUT:{}".format(stdout))
            LOG.debug("Setup Return STDERR:{}".format(stderr))

            if 'myproject' in self.repo.setup_scripts:
                deploy_path = os.path.join(deploy_path, 'myproject')

        manage_files = utils.search_file(deploy_path, 'manage.py')
        if not manage_files:
            LOG.error("Can not find manage.py!")
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        manage_paths = [os.path.dirname(manage_file) for manage_file in manage_files]
        base_dir = next(name for name in manage_paths if 'lib/python2.7/site-packages/' not in name)
        manage_path = next(name for name in manage_paths if name.startswith(base_dir))
        LOG.info('manage.py path: {}'.format(manage_path))

        with open(os.path.join(manage_path, 'manage.py'), 'r') as manage_file:
            s = re.search('os.environ.setdefault\("DJANGO_SETTINGS_MODULE", "(.*)"\)', manage_file.read())
            if s:
                setting_path = s.group(1)
            else:
                setting_paths = utils.search_file(deploy_path, 'settings.py')
                if len(setting_paths) > 0:
                    setting_path = setting_paths[0][:-3]
                else:
                    LOG.error("Can not find settings.py")
                    return ATTEMPT_STATUS_MISSING_REQUIRED_FILES

        setting_path = setting_path.replace('.', '/')
        if os.path.isdir(os.path.join(manage_path, setting_path)):
            setting_path = os.path.join(manage_path, setting_path)
            for setting_file in sorted(os.listdir(setting_path)):
                if os.path.isfile(os.path.join(setting_path, setting_file)):
                    setting_path = os.path.join(setting_path, setting_file)
                    break
            self.setting_path = setting_path
        elif os.path.isfile(os.path.join(manage_path, setting_path + '.py')):
            setting_path = os.path.join(manage_path, setting_path + '.py')
            self.setting_path = setting_path
        else:
            for candidate_setting_files in utils.search_file_regex(deploy_path, '^settings.*\.py$'):
                setting_path = os.path.join(manage_path, setting_path + '.py')
                utils.copy_file(candidate_setting_files, setting_path)
                self.setting_path = setting_path
                break

        if self.setting_path == None:
            LOG.error("Can not find settings.py!")
            return ATTEMPT_STATUS_MISSING_REQUIRED_FILES
        LOG.info('setting.py path: {}'.format(setting_path))

        requirement_files = utils.search_file(deploy_path, 'requirements.txt')
        if requirement_files:
            LOG.info('requirements.txt path: {}'.format(requirement_files))

        return self.try_deploy(manage_path, requirement_files)
Example #18
0
from network import U_Net
from utils import search_file
import cv2
import numpy as np
from utils import COLOR_DICT
from utils import dense_crf
from PIL import Image
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
# 是否使用cuda
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
num_classes = 3
num_channels = 3
batch_size = 4
size = (512, 384)
root = "membrane/test"
img_file = search_file(root, [".jpg"])
print(len(img_file))
# print(img_file)
if __name__ == "__main__":
    model = U_Net(num_channels, num_classes).to(device)
    model.load_state_dict(torch.load('UNet_weights_bilinear_weight.pth'))
    model.eval()
    with torch.no_grad():
        for i in range(len(img_file)):
            print(img_file[i])
            save_path = os.path.join(
                "membrane1/result",
                os.path.basename(img_file[i])[0:-4] + ".png")
            print(save_path)
            input = cv2.imread(img_file[i], cv2.IMREAD_COLOR)
            input = cv2.resize(input, size)