Show any RAR5 record.
196708
def show_item_v5(h):
    
    st = rar5_type(h.block_type)
    xprint("%s: hdrlen=%d datlen=%d hdr_extra=%d", st, h.header_size,
           h.compress_size, h.block_extra_size)
    xprint("  block_flags=0x%04x:%s", h.block_flags, render_flags(h.block_flags, r5_block_flags))
    if h.block_type in (rf.RAR5_BLOCK_FILE, rf.RAR5_BLOCK_SERVICE):
        xprint("  name=%s", h.filename)
        if h.file_host_os == rf.RAR5_OS_UNIX:
            s_os = 'UNIX'
            s_mode = "0%o" % h.mode
        else:
            s_os = 'WINDOWS'
            s_mode = "0x%x" % h.mode
        xprint("  file_flags=0x%04x:%s", h.file_flags, render_flags(h.file_flags, r5_file_flags))

        cmp_flags = h.file_compress_flags
        xprint("  cmp_algo=%d cmp_meth=%d dict=%d solid=%r",
               cmp_flags & 0x3f,
               (cmp_flags >> 7) & 0x07,
               cmp_flags >> 10,
               cmp_flags & rf.RAR5_COMPR_SOLID > 0)
        xprint("  os=%d:%s mode=%s cmp=%r dec=%r vol=%r",
               h.file_host_os, s_os, s_mode,
               h.compress_size, h.file_size, h.volume)
        if h.CRC is not None:
            xprint("  crc=0x%08x (%d)", h.CRC, h.CRC)
        if h.blake2sp_hash is not None:
            xprint("  blake2sp=%s", rf.tohex(h.blake2sp_hash))
        if h.date_time is not None:
            xprint("  date_time=%s", fmt_time(h.date_time))
        if h.mtime:
            xprint("  mtime=%s", fmt_time(h.mtime))
        if h.ctime:
            xprint("  ctime=%s", fmt_time(h.ctime))
        if h.atime:
            xprint("  atime=%s", fmt_time(h.atime))
        if h.arctime:
            xprint("  arctime=%s", fmt_time(h.arctime))
        if h.flags & rf.RAR_FILE_PASSWORD:
            enc_algo, enc_flags, kdf_count, salt, iv, checkval = h.file_encryption
            algo_name = 'AES256' if enc_algo == rf.RAR5_XENC_CIPHER_AES256 else 'UnknownAlgo'
            xprint('  algo=%d:%s enc_flags=%04x:%s kdf_lg=%d kdf_count=%d salt=%s iv=%s checkval=%s',
                   enc_algo, algo_name, enc_flags, render_flags(enc_flags, r5_file_enc_flags),
                   kdf_count, 1 << kdf_count, rf.tohex(salt), rf.tohex(iv),
                   checkval and rf.tohex(checkval) or '-')
        if h.file_redir:
            redir_type, redir_flags, redir_name = h.file_redir
            xprint('  redir: type=%s flags=%d:%s destination=%s',
                   r5_file_redir_types.get(redir_type, 'Unknown'),
                   redir_flags, render_flags(redir_flags, r5_file_redir_flags),
                   redir_name)
        if h.file_owner:
            uname, gname, uid, gid = h.file_owner
            xprint('  owner: name=%r group=%r uid=%r gid=%r',
                   uname, gname, uid, gid)
        if h.file_version:
            flags, version = h.file_version
            xprint('  version: flags=%r version=%r', flags, version)
    elif h.block_type == rf.RAR5_BLOCK_MAIN:
        xprint("  flags=0x%04x:%s", h.flags, render_flags(h.main_flags, r5_main_flags))
    elif h.block_type == rf.RAR5_BLOCK_ENDARC:
        xprint("  flags=0x%04x:%s", h.flags, render_flags(h.endarc_flags, r5_endarc_flags))
    elif h.block_type == rf.RAR5_BLOCK_ENCRYPTION:
        algo_name = 'AES256' if h.encryption_algo == rf.RAR5_XENC_CIPHER_AES256 else 'UnknownAlgo'
        xprint("  algo=%d:%s flags=0x%04x:%s", h.encryption_algo, algo_name, h.flags,
               render_flags(h.encryption_flags, r5_enc_flags))
        xprint("  kdf_lg=%d kdf_count=%d", h.encryption_kdf_count, 1 << h.encryption_kdf_count)
        xprint("  salt=%s", rf.tohex(h.encryption_salt))
    else:
        xprint("  - missing info -")

    if h.comment is not None:
        cm = repr(h.comment)
        if cm[0] == 'u':
            cm = cm[1:]
        xprint("  comment=%s", cm)
647218
def _make_record(self,row):
        """"""
        res = dict(zip(self.all_fields,row))
        for k in self.types:
            res[k] = self.types[k](res[k])
        return res
1007529
def _get_rar_version(xfile):
    
    buf = xfile.read(len(RAR5_ID))
    if buf.startswith(RAR_ID):
        return 3
    elif buf.startswith(RAR5_ID):
        xfile.read(1)
        return 5
    return 0
572060
def show_files(md5):
    ''''''
    if not WORKBENCH:
        return flask.redirect('/')

    md5_view = WORKBENCH.work_request('view', md5)
    return flask.render_template('templates/md5_view.html', md5_view=md5_view['view'], md5=md5)
625749
def _get_record(self, record_type):
        """"""
        if not self.has_record_type(record_type):
            raise errors.Unsupported()
        if str(record_type) not in self._records:
            raise errors.Unimplemented()
        return self._records[str(record_type)]
697014
def record(self, i=0):
        """"""
        f = self.__getFileObj(self.dbf)
        if self.numRecords is None:
            self.__dbfHeader()
        i = self.__restrictIndex(i)
        recSize = self.__recStruct.size
        f.seek(0)
        f.seek(self.__dbfHdrLength + (i * recSize))
        return self.__record(oid=i)
964917
def recorded(self):
        """"""
        if self.tune and self.tune.get('@src'):
            return True if self.tune.get('@src').startswith('mbr') else False
        else:
            raise PyMediaroomError("No information in <node> about @src")
741609
def record(self, rr_version):
        # type: (str) -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('PX record not yet initialized!')

        outlist = [b'PX', struct.pack('=BBLLLLLLLL', RRPXRecord.length(rr_version),
                                      SU_ENTRY_VERSION, self.posix_file_mode,
                                      utils.swab_32bit(self.posix_file_mode),
                                      self.posix_file_links,
                                      utils.swab_32bit(self.posix_file_links),
                                      self.posix_user_id,
                                      utils.swab_32bit(self.posix_user_id),
                                      self.posix_group_id,
                                      utils.swab_32bit(self.posix_group_id))]
        if rr_version == '1.12':
            outlist.append(struct.pack('=LL', self.posix_serial_number,
                                       utils.swab_32bit(self.posix_serial_number)))
        # The rr_version can never be "wrong" at this point; if it was, it would
        # have thrown an exception earlier when calling length().  So just skip
        # any potential checks here.

        return b''.join(outlist)
874789
def emit(self, record):
        
        try:
            # Shorten the source name of the record (remove rafcon.)
            if sys.version_info >= (2, 7):
                record.__setattr__("name", record.name.replace("rafcon.", ""))
            msg = self.format(record)
            fs = "%s"
            try:
                ufs = u'%s'
                try:
                    entry = ufs % msg
                except UnicodeEncodeError:
                    entry = fs % msg
            except UnicodeError:
                entry = fs % msg

            for logging_view in self._logging_views.values():
                logging_view.print_message(entry, record.levelno)
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)
1098203
def record(self):
        

        modules = []
        scripts = []
        if self.get_content_of_file('RECORD'):
            lines = self.get_content_of_file('RECORD').splitlines()
            for line in lines:
                if 'dist-info' in line or '/' not in line:
                    continue
                elif '.data/scripts' in line:
                    script = line.split(',', 1)[0]
                    # strip Name.version.data/scripts/
                    scripts.append(re.sub('.*/.*/', '', script))
                else:
                    # strip everything from first occurance of slash
                    modules.append(re.sub('/.*', '', line))

        return {'modules': sorted(set(modules)),
                'scripts': sorted(set(scripts))}
219525
def geist_replay(wrapped, instance, args, kwargs):
    """"""
    path_parts = []
    file_parts = []

    if hasattr(wrapped, '__module__'):
        module = wrapped.__module__
        module_file = sys.modules[module].__file__
        root, _file = os.path.split(module_file)
        path_parts.append(root)
        _file, _ = os.path.splitext(_file)
        file_parts.append(_file)
    if hasattr(wrapped, '__objclass__'):
        file_parts.append(wrapped.__objclass__.__name__)
    elif hasattr(wrapped, '__self__'):
        file_parts.append(wrapped.__self__.__class__.__name__)
    file_parts.append(wrapped.__name__ + '.log')
    path_parts.append('_'.join(file_parts))
    filename = os.path.join(*path_parts)

    if is_in_record_mode():
        platform_backend = get_platform_backend()
        backend = RecordingBackend(
            source_backend=platform_backend,
            recording_filename=filename
        )
    else:
        backend = PlaybackBackend(
            recording_filename=filename
        )
    gui = GUI(backend)
    return wrapped(gui, *args, **kwargs)
423758
def maybe_start_recording(tokens, index):
        """"""
        if tokens[index].type == TokenType.BeginRSTComment:
            return _RSTCommentBlockRecorder(index, tokens[index].line)

        return None
1000443
def records(self):
        """"""
        return ModelList(*[r for sent in self.sentences for r in sent.records])
437282
def discands(record):
    """"""
    import pyfits
    pyraf.iraf.images()
    pyraf.iraf.images.tv()
    display = pyraf.iraf.images.tv.display
    
    width=128
    
    cands = record['cands']
    exps=   record['fileId']
    comments= record['comments']

    ### load some header info from the mophead file
    headers={}
    for exp in exps:
        f = pyfits.open(exp+".fits")
        headers[exp]={}
        for key in ['MJDATE', 'NAXIS1', 'NAXIS2', 'EXPTIME', 'FILTER']:
            headers[exp][key]=f[0].header[key]
        headers[exp]['MJD-OBSC']=headers[exp]['MJDATE']+headers[exp]['EXPTIME']/2.0/3600.0/24.0
        f.close()

    import math,os
    real=0
    cand_total=len(cands)
    if cand_total > 100 :
        sys.stderr.write("Too many candidates (%d) skipping this chip...\n" % ( cand_total))
	return -1
    for cand in cands:
        cand_total=cand_total-1
        x2=[]
        y2=[]
        y1=[]
        x1=[]
        for i in range(len(exps)):
	    #print exps[i]
            fileId=exps[i]
            x2.append(int(min(math.floor(cand[i]['x'])+width,headers[fileId]['NAXIS1'])))
            y2.append(int(min(math.floor(cand[i]['y'])+width,headers[fileId]['NAXIS2'])))
            x1.append(int(max(math.floor(cand[i]['x'])-width,1)))
            y1.append(int(max(math.floor(cand[i]['y'])-width,1)))
	#print exps
	#print x1,x2
	#print y1,y2
        x_1 = min(x1)
        y_1 = min(y1)
        x_2 = max(x2)
        y_2 = max(y2)
	ans='f'
	fake=True
	xshifts=[]
	yshifts=[]
	first_pass=True
	show_coords=True
	ans='j'
	while ( first_pass or ans == 'f' or ans == 'c') : 
	  first_pass=False
	  if ans=='c':
	    if show_coords: 
	       show_coords=False
            else:
	       show_coords=True
	  if ans=='f':
	    if fake:
	       fake=False
	    else:
	       fake=True
          for i in range(len(exps)):
            xshift=cand[i]['x']-cand[i]['x_0']
            yshift=cand[i]['y']-cand[i]['y_0']
	    allmark=open('all.coo','w')
	    for j in range(len(exps)):
	      if j==i :
	         continue
              allmark.write('%f %f\n' % ( cand[j]['x_0']+xshift, cand[j]['y_0']+yshift))
	    allmark.close()
            tvmark=open('tv.coo','w')
            tvmark.write('%f %f %d\n' % ( cand[i]['x'], cand[i]['y'], cand_total))
            x1=max(x_1 + xshift,1)
            y1=max(y_1 + yshift,1)
            x2=min(x_2 + xshift,headers[exps[i]]['NAXIS1'])
            y2=min(y_2 + yshift,headers[exps[i]]['NAXIS2'])
            cutout = "[%d:%d,%d:%d]" % (x1,x2,y1,y2)
	    if not fake:
	       if exps[i][0:2]=='fk' :
	         fileId=exps[i][2:]
	       else:
                 fileId=exps[i]
            else:
               fileId=exps[i]
#	    sys.stdout.write("---> ",fileId+cutout,xshift,yshift
            try:
                junk=display(fileId+cutout,i+1,Stdout=1)
            except:
                sys.stderr.write("ERROR\n")
            tvmark.close()
	    if show_coords:
              pyraf.iraf.images.tv.tvmark(i+1,'all.coo',mark='circle',radii=10,color=205)
              pyraf.iraf.images.tv.tvmark(i+1,'tv.coo',mark='circle',radii=8,color=204,label='yes',nxoffset=10)
            os.unlink('tv.coo')
	    os.unlink('all.coo')
        ### ask if this is a real candidate, take action.
          ans='j'
          while ans not in ('y', 'n', 'q', 's', 'f', 'c'):
            ans=raw_input("[%d] (y,n,s,q,c,f) : " % ( cand_total))
        if ans=='y':
	    if os.access("cands.REAL",os.W_OK):
                f=open("cands.REAL","a")
 	    else:
                f=open("cands.REAL","w")
	        for comment in comments:
		    f.write(comment)
            cols=['x','y','x_0','y_0','flux','size','max_int','elon']
            #for col in cols:
            #    f.write("%s\t" % col)
            f.write("\n")
            for ii in range(len(exps)):
                for col in cols:
                    f.write("%8.2f\t" % cand[ii][col])
                f.write("\n")
            f.close()
            real=real+1
        if ans=='q':
            return -2
	if ans=='s':
	    return -1
    return real
952833
def start_record():
    
    global record, playback, current
    if record:
        raise StateError("Already recording.")
    if playback:
        raise StateError("Currently playing back.")
    record = True
    current = ReplayData()
    install(RecordingHTTPConnection, RecordingHTTPSConnection)
414559
def _get_first_all_link_record(self):
        """"""
        _LOGGER.debug("Starting: _get_first_all_link_record")
        _LOGGER.info('Requesting ALL-Link Records')
        if self.aldb.status == ALDBStatus.LOADED:
            self._next_all_link_rec_nak_retries = 3
            self._handle_get_next_all_link_record_nak(None)
            return
        self.aldb.clear()
        self._next_all_link_rec_nak_retries = 0
        msg = GetFirstAllLinkRecord()
        self.send_msg(msg, wait_nak=True, wait_timeout=.5)
        _LOGGER.debug("Ending: _get_first_all_link_record")
1361967
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('RR record not yet initialized!')

        return b'RR' + struct.pack('=BBB', RRRRRecord.length(), SU_ENTRY_VERSION, self.rr_flags)