def exec_report(self, name, data, context={}):
     datas = data.copy()
     ids = datas['ids']
     del datas['ids']
     if not ids:
         ids =  rpc.session.rpc_exec_auth('/object', 'execute', datas['model'], 'search', datas.get('_domain',[]))
         if ids == []:
             common.message(_('Nothing to print!'))
             return False
         datas['id'] = ids[0]
     ctx = rpc.session.context.copy()
     ctx.update(context)
     report_id = rpc.session.rpc_exec_auth('/report', 'report', name, ids, datas, ctx)
     state = False
     attempt = 0
     max_attemps = int(options.options.get('client.timeout') or 0)
     while not state:
         val = rpc.session.rpc_exec_auth('/report', 'report_get', report_id)
         if not val:
             return False
         state = val['state']
         if not state:
             time.sleep(1)
             attempt += 1
         if attempt>max_attemps:
             common.message(_('Printing aborted, too long delay !'))
             return False
     printer.print_data(val)
     return True
Exemple #2
0
 def exec_report(self, name, data, context={}):
     datas = data.copy()
     ids = datas['ids']
     del datas['ids']
     if not ids:
         ids = rpc.session.rpc_exec_auth('/object', 'execute',
                                         datas['model'], 'search', [])
         if ids == []:
             common.message(_('Nothing to print!'))
             return False
         datas['id'] = ids[0]
     ctx = rpc.session.context.copy()
     ctx.update(context)
     report_id = rpc.session.rpc_exec_auth('/report', 'report', name, ids,
                                           datas, ctx)
     state = False
     attempt = 0
     max_attemps = int(options.options.get('client.timeout') or 0)
     while not state:
         val = rpc.session.rpc_exec_auth('/report', 'report_get', report_id)
         if not val:
             return False
         state = val['state']
         if not state:
             time.sleep(1)
             attempt += 1
         if attempt > max_attemps:
             common.message(_('Printing aborted, too long delay !'))
             return False
     printer.print_data(val)
     return True
Exemple #3
0
def main():
    parser = argparse.ArgumentParser(
        description='Get Star Wars data from SWAPI')
    parser.add_argument('--format',
                        choices=['json', 'text', 'list'],
                        default='text',
                        help='output format')
    parser.add_argument(
        '--fields',
        help=
        'print only specific fields (coma-separated list). eg: \'name,population,terrain\''
    )
    parser.add_argument(
        '--filter',
        nargs=3,
        action='append',
        help='field_name operator value. eg: \'name = Tatooine\'')
    parser.add_argument('--nocache',
                        action='store_true',
                        help='disable requests cache')
    parser.add_argument('resource', help='resource to get')
    args = parser.parse_args()

    fields = []
    if args.fields is not None:
        fields = list(map(str.strip, args.fields.split(sep=',')))

    try:
        data = swcli(args.resource,
                     filter_cmds=args.filter,
                     cache=not (args.nocache))
    except Exception as err:
        print("ERROR: %s" % err, file=sys.stderr)
        exit(1)

    if not data:
        print("No results", file=sys.stderr)
        exit(1)

    printer.print_data(data, args.format, fields)
Exemple #4
0
    thorings = monomer.mark_thio(monomer1)
    intermono = monomer.find_intermono(monomer1)
    halfmono = monomer.get_single_alist(monomer1)
    attach = monomer.find_attach(monomer1,halfmono)
    test2 = monomer.attach(halfmono,attach,monomer1,length)
    monomer.print_mono(test2,"outputs/test")
    #monomer.create_polymer_cml(mname,halfmono,attach,monomer1)
    sys.stdout = sys.__stdout__

#create babel and read to get better partials
babel.read_babel_set(mname,atoms)
atom.adjust_partials(atoms)

#write different dft finders
#write_nwchem.dft(dihedrals)
#write_qchem.write(atoms,dihedrals)
sys.stdout = sys.__stdout__

if debug:
    printer.debug(atoms,bonds,angles,dihedrals,rings,fused_rings,opls_atoms,opls_bonds,opls_angles,opls_dihedrals)

#print all the output files
printer.print_data(dname,atoms,bonds,angles,dihedrals,unique_a,unique_b,unique_ang,unique_d,xmin,xmax,ymin,ymax,zmin,zmax)
if help == False or isfile == False:
    printer.print_lammpsin(inname,dataname,lammpsinput)
sys.stdout = sys.__stdout__
printer.print_srun(lammpsinput)

#autorun
#os.system('sbatch run_%s' % lammpsinput)