예제 #1
0
def backup():
    log.info('Backing up shared file lists...')
    source = config.get_shared_file_lists_dir()
    if not exists(source):
        log.info('Warning: ' + source + ' does not exist.')
        log.info('Shared file backup failed.')
        return
    dest = config.get_shared_file_lists_backup_dir()
    copy_dir(source, dest)
예제 #2
0
def backup():
    print 'Backing up shared file lists...'
    source = config.get_shared_file_lists_dir()
    if not exists(source):
        print 'Warning: ' + source + ' does not exist.'
        print 'Shared file backup failed.'
        return
    dest = config.get_shared_file_lists_backup_dir()
    copy_dir(source, dest)
예제 #3
0
def restore():
    source = get_ssh_backup_dir()
    if not exists(source):
        log.info('No .ssh dir found... skipping.')
        return
    log.info('Restoring .ssh dir...')
    dest = get_ssh_user_dir()
    copy_dir(source, dest, with_sudo=True)
    ensure_dir_owned_by_user(dest, get_user())
예제 #4
0
def backup():
    source = get_ssh_user_dir()
    if not exists(source):
        log.info('No .ssh dir found... skipping.')
        return
    log.info('Backing up .ssh dir...')
    dest = get_ssh_backup_dir()
    ensure_exists(dest)
    copy_dir(source, dest)
예제 #5
0
def backup():
    source = get_ssh_user_dir()
    if not exists(source):
        print 'No .ssh dir found... skipping.'
        return
    print 'Backing up .ssh dir...'
    dest = get_ssh_backup_dir()
    ensure_exists(dest)
    copy_dir(source, dest)
예제 #6
0
def main():

    args = parser.parse_args()
    if args.src is None:
        raise Exception('No source path has been given')
    if args.src is None:
        raise Exception('No target path has been given')

    folders = list_repo(args.src, onlyRepo=True)

    copy_dir(args.src, args.tgt)

    alpha2color = {0.85: 0, 1: 255}
    masker = MaskHandler(NUM_CLASS, alpha2color)
    sampler = Sampler(masker)
    unet = Unet(NUM_CLASS)

    unet.model = load_model(args.model)
    print('Model loaded')

    for f in folders:
        print('##')
        print(f)
        print('##')
        im_infer = list_repo(args.src + f + '/')
        print('Found', len(im_infer), 'images to detour')
        eligible = [img for img in im_infer if sampler.is_eligible(img)]
        z = sampler.generateTest(eligible)
        print('Images prepared for inference')
        inference = unet.model.predict(z)
        for IDX in range(inference.shape[0]):
            print('Prediction', IDX + 1, 'done')
            unmasked = masker.unmask(eligible[IDX],
                                     inference[IDX],
                                     show=False,
                                     imgFromNpy=False,
                                     maskFromPredNpy=True,
                                     convertToColor=True,
                                     save_folder_path=args.tgt +
                                     get_img_name(eligible[IDX]) + '.png')
예제 #7
0
def backup_user_launch_agents():
    source = config.get_user_launch_agents_dir()
    dest = config.get_user_launch_agents_backup_dir()
    copy_dir(source, dest)
예제 #8
0
import os
import shutil
import stat
from utils import copy_dir

source_lib = r"D:\ku\react-router-pro\lib"


class Path(object):
    def __init__(self, path):
        self.lib = path + "/lib"


arr = [
    Path('D:/oppo_pro/esa-admin/node_modules/react-router-pro'),
    Path('D:/oppo_pro/ddp-h5/node_modules/react-router-pro'),
]

for i in arr:
    #del_dir(i.lib)
    copy_dir(source_lib, i.lib)
예제 #9
0
    test_data = loader.RNN_Dataset((test_padded, test_seq_len_list),
                                   type='Classification')
    test_loader = DataLoader(dataset=test_data,
                             batch_size=batch_size,
                             shuffle=False)
    test_loss, test_size = utils.eval_rnn_classification(
        test_loader, model, device, output_size, criterion1, criterion2,
        num_class1, num_class2)
    print('test loss : {:.4f}'.format(test_loss))
    # writer.add_scalar('Loss/Test', test_loss/test_size, 1)


if __name__ == '__main__':
    args.save_result_root += args.model_type + '_' + args.target_type + '/'
    dateTimeObj = datetime.now()
    timestampStr = dateTimeObj.strftime("%b%d_%H%M%S/")
    args.save_result_root += timestampStr
    print('\n|| save root : {}\n\n'.format(args.save_result_root))
    utils.copy_file(args.bash_file,
                    args.save_result_root)  # .sh file 을 새 save_root에 복붙
    utils.copy_dir(
        './src', args.save_result_root +
        'src')  # ./src 에 code를 모아놨는데, src folder를 통째로 새 save_root에 복붙
    if args.target_type == 'regression':
        mlp_regression(args)
    elif args.target_type == 'cls':
        mlp_cls(args)

# run_regression('dbp')
# rnn('sbp')
예제 #10
0
def restore():
    log.info('Restoring shared file lists...')
    dest = config.get_shared_file_lists_dir()
    source = config.get_shared_file_lists_backup_dir()
    copy_dir(source, dest, with_sudo=True)
    ensure_dir_owned_by_user(dest, config.get_user())
예제 #11
0
def restore_system_daemons_agents():
    source = config.get_system_launch_daemons_backup_dir()
    dest = config.get_system_launch_daemons_dir()
    copy_dir(source, dest, with_sudo=True)
    ensure_dir_owned_by_user(dest, 'root:wheel', '644')
예제 #12
0
def restore():
    source = get_pm_backup_path()
    dest = get_pm_path()
    log.info('Restoring system preferences...')
    copy_dir(source, dest, with_sudo=True)
    ensure_files_owned_by_user('root:wheel', [dest], '644')
예제 #13
0
def backup():
    print 'Backing up system preferences... '
    source = get_pm_path()
    dest = get_pm_backup_path()
    copy_dir(source, dest)
예제 #14
0
def test_copy_dir_works_with_sudo(execute_shell_mock):
    utils.copy_dir('src', 'dest', with_sudo=True)
    execute_shell_mock.assert_called_with(
        ['sudo', 'rsync', '-a', 'src', 'dest'])
예제 #15
0
def test_copy_dir(execute_shell_mock):
    utils.copy_dir('src', 'dest')
    execute_shell_mock.assert_called_with(['rsync', '-a', 'src', 'dest'])
예제 #16
0
def test_copy_dir(execute_shell_mock, level_mock):
    level_mock.return_value = log.DEBUG
    utils.copy_dir('src', 'dest')
    execute_shell_mock.assert_called_with(
        ['rsync', '-a', '-vv', 'src', 'dest'])
예제 #17
0
def backup():
    log.info('Backing up preferences (.plist)...')
    source = get_preferences_dir()
    dest = get_preferences_backup_dir()
    copy_dir(source, dest)
예제 #18
0
def backup_system_daemons_agents():
    source = config.get_system_launch_daemons_dir()
    dest = config.get_system_launch_daemons_backup_dir()
    copy_dir(source, dest)
예제 #19
0
def restore_user_launch_agents():
    source = config.get_user_launch_agents_backup_dir()
    dest = config.get_user_launch_agents_dir()
    copy_dir(source, dest, with_sudo=True)
    ensure_dir_owned_by_user(dest, config.get_user())
예제 #20
0
def backup():
    log.info('Backing up system preferences... ')
    source = get_pm_path()
    dest = get_pm_backup_path()
    copy_dir(source, dest)
예제 #21
0
파일: __init__.py 프로젝트: lnsoso/parm
    def handle(self, options, global_options, *args):
        from utils import extract_dirs, copy_dir
        from par.bootstrap_ext import blocks
        from md_ext import new_code_comment, toc
        from functools import partial

        if not conf:
            log.error('Current directory is not a parm project')
            sys.exit(1)
            
        #make output directory
        if not os.path.exists(options.directory):
            print 'Make directories [%s]' % options.directory
            os.makedirs(options.directory)
            
        #copy static files
        print 'Copy default templates/static to %s' % options.directory
        extract_dirs('parm', 'templates/static', 
            os.path.join(options.directory, 'static'))
            
        #create source directory
        source_path = os.path.join(options.directory, 'source')
        if not os.path.exists(source_path):
            print 'Make directories [%s]' % source_path
            os.makedirs(source_path)
        
        #compile markdown files
        files = list(os.listdir('.'))
        headers = {}
        relations = {}
        
        #prepare block process handlers
        blocks['code-comment'] = new_code_comment
        blocks['toc'] = partial(toc, headers=headers, relations=relations)

        output_files = {}
        
        while 1:
            if not files:
                break
            
            path = files.pop(0)
            fname, ext = os.path.splitext(path)
            if os.path.isfile(path) and (ext in conf.source_suffix):
                if fname == conf.master_doc and len(files)>1:
                    files.append(path)
                    continue
                
                with open(path) as f:
                    
                    data = {}
                    data['conf'] = conf
                    
                    #process markdown convert
                    data['body'] = parseHtml(f.read(), 
                        '', 
                        conf.tag_class,
                        block_callback=blocks)
                    page_nav = relations.get(fname, {})
                    data['prev'] = page_nav.get('prev', {})
                    data['next'] = page_nav.get('next', {})
                    data['source'] = '<a href="source/%s">%s</a>' % (path, conf.download_source)
                    
                    #parse header from text
                    h = headers.setdefault(path, [])
                    title = self.parse_headers(path, data['body'], h)
                    if title:
                        data['title'] = unicode(title, 'utf8') + ' - ' + conf.project 
                    else:
                        print 'Error: Heading 1 not found in file %s' % path
                        continue

                    #convert conf attributes to data
                    for k in dir(conf):
                        if not k.startswith('_'):
                            data[k] = getattr(conf, k)
                       
                    #process template
                    template_file = conf.templates.get(fname, conf.templates.get('*', 'default.html'))
                    hfilename = os.path.join(options.directory, fname + '.html').replace('\\', '/')
                    with open(hfilename, 'wb') as fh:
                        print 'Convert %s to %s' % (path, hfilename)
                        fh.write(template.template_file(template_file, data, dirs=['_build']))
                
                    output_files[fname] = hfilename
                    #copy source file
                    sfilename = os.path.join(source_path, path)
                    shutil.copy(path, sfilename)
                    
            elif os.path.isdir(path) and not path.startswith('_'):
                print 'Copy %s to %s' % (path, options.directory)
                copy_dir(path, os.path.join(options.directory, path))
                
        prev_next_template_top = """{{if prev:}}<div class="chapter-prev chapter-top">
    <a prev-chapter href="{{<< prev['link']}}"><i class="icon-arrow-left"></i> {{=prev['title']}}</a>
</div>{{pass}}
{{if next:}}<div class="chapter-next chapter-top">
    <a next-chapter href="{{<< next['link']}}">{{=next['title']}} <i class="icon-arrow-right"></i></a>
</div>{{pass}}"""
        prev_next_template_down = """{{if prev:}}<div class="chapter-prev chapter-down">
    <a prev-chapter href="{{<< prev['link']}}"><i class="icon-arrow-left"></i> {{=prev['title']}}</a>
</div>{{pass}}
{{if next:}}<div class="chapter-next chapter-down">
    <a next-chapter href="{{<< next['link']}}">{{=next['title']}} <i class="icon-arrow-right"></i></a>
</div>{{pass}}"""
        
        for name, f in output_files.items():
            text = open(f, 'rb').read()
            
            x = relations.get(name, {})
            data = {}
            data['prev'] = x.get('prev', {})
            data['next'] = x.get('next', {})
            
            prev_next_text_top = template.template(prev_next_template_top, data)
            prev_next_text_down = template.template(prev_next_template_down, data)
            text = text.replace('<!-- prev_next_top -->', prev_next_text_top)
            text = text.replace('<!-- prev_next_down -->', prev_next_text_down)
            with open(f, 'wb') as fh:
                fh.write(text)
예제 #22
0
파일: copy.py 프로젝트: aiyuekuang/clothe
import os
import shutil
import stat
from utils import copy_dir

source_dist = r"D:\ku\clothe\dist"
source_lib = r"D:\ku\clothe\lib"


class Path(object):
    def __init__(self,path):
        self.dist = path +"/dist"
        self.lib = path +"/lib"


arr = [Path('D:/oppo_pro/esa-admin/node_modules/clothe'),Path('D:/auto/zhWeb/node_modules/clothe'),Path('D:/oppo_pro/ddp_online/node_modules/clothe'),Path('D:/oppo_pro/ddp-admin/node_modules/clothe'),Path('E:/ztao/autoElevator/node_modules/clothe')]



for i in arr:
    #del_dir(i.dist)
    copy_dir(source_dist,i.dist)
    #del_dir(i.lib)
    copy_dir(source_lib,i.lib)
예제 #23
0
def restore():
    print 'Restoring preferences (.plist)...'
    source = get_preferences_backup_dir()
    dest = get_preferences_dir()
    copy_dir(source, dest, with_sudo=True)
    ensure_dir_owned_by_user(dest, get_user())
예제 #24
0
def backup():
    print 'Backing up preferences (.plist)...'
    source = get_preferences_dir()
    dest = get_preferences_backup_dir()
    copy_dir(source, dest)