; Convert first byte from a string to an unsigned 8-bit integer.iN(sordss(ss((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysReadInt1scCs(t|dd>t|dd>SdS(sDConvert first two bytes from a string to an unsigned 16-bit integer.iiiN(sordss(ss((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysReadInt2#scCstt|dd>t|dd>t|dd>t|dd>}yt|}|SWntj o |SnXdS( s/Convert first four bytes from a string to an unsigned 32-bit integer. Returns integer | long In Python on a 32-bit machine, integers are signed and within the range -2^31 .. (2^31 - 1). If the 32-bit integer fits within this range, an integer is returned, otherwise a long is returned.iiiiiiiN(slongsordsssl4sintsi4s OverflowError(sssl4si4((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysReadInt4(sP cCst|d@SdS(sCConverts an unsigned 8-bit integer/long into a string, 1 byte long.iN(schrsi(si((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysPackInt1;scCs(t|d?d@t|d?d@SdS(sDConverts an unsigned 16-bit integer/long into a string, 2 byte long.iiiN(schrsi(si((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysPackInt2?scCsLt|d?d@t|d?d@t|d?d@t|d?d@SdS(sDConverts an unsigned 32-bit integer/long into a string, 4 byte long.iiiiiN(schrsi(si((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysPackInt4DsicCs#|ot|Sn t|SdS(sMake sure the node name is a valid node name. NODE-NAME = string A node name, possibly containing an "@" USE-SHORT-NODE-NAMES = bool Whether to align using short node names or not. If not, then long node names are assumed. Returns: string Throws: nothing The returned node name: 1. If the NODE-NAME contains an `@', then NODE-NAME is returned unchanged 2. If the NODE-NAME does not contain an `@', then the returned node name is constructed as NODE-NAME + "@" + host-name, where host-name is either on short or long form, depending on USE-SHORT-NODE-NAMES. N(suseShortNodeNamessAlignShortNodeNamesnodeNamesAlignLongNodeName(snodeNamesuseShortNodeNames((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys AlignNodeNameLscCsDd|jo|Snt}ti|dd}|d|SdS(sEAlign a node, use short hostname if needed. See doc for AlignNodeNames@s.iN(snodeNamesGetFullyQualifiedHostNamesfqdnsstringssplits shortHostName(snodeNames shortHostNamesfqdn((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysAlignShortNodeNamefs   cCs.d|jo|Snt}|d|SdS(sDAlign a node, use long hostname if needed. See doc for AlignNodeNames@N(snodeNamesGetFullyQualifiedHostNamesfqdn(snodeNamesfqdn((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysAlignLongNodeNamens   scCsyti|SWntj o}ti|}| p |djoti}nyti|\}}}Wnt j on;X|i d|x&|D]}d|joPqqW|}|SnXdS(s Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname is returned. s0.0.0.0is.N(ssocketsgetfqdnsnamesAttributeErrorsinfosstringsstrips gethostnames gethostbyaddrshostnamesaliasessipaddrsserrorsinsert(snamesinfosipaddrsshostnamesaliases((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysGetFullyQualifiedHostNameus$  cCs*tii|oti|SndSdS(sRead an environment variable. ENV-NAME = string The name of the environment variable Returns: "" | string The env-value, or "" if the env-name isn't defined Throws: nothing sN(sossenvironshas_keysenvName(senvName((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysgetenvscCs tttt||SdS(s~Given a sequence, return a list of tuples (i, elem[i]). Example: IndexSeq(["a", "b", "c"]) ==> [(0, "a"), (1, "b"), (2, "c")].N(smapsNonesrangeslensseq(sseq((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysIndexSeqscCsdS(sSetup a file name to log to FILE-NAME = string The name of a file to log to Returns: void Sets up a log file. N((sfileName((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys SetLogFilescCsnttjo]yAttd}|i||id|i|iWqjtj o }qjXndS(s+Log a string to the log file STR = string The string to log (without trailing new-line) Returns: void Throws: nothing Logs a string to the file set up by logfilename. The file is opened only during the logging. It is kept closed between calls to this function. sws N( s _logfilenamesNonesopensfswritesstrsflushsclosesIOErrorsinfo(sstrsinfosf((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysLogs     icCs |adS(sSetup a file name to print debugging messages to FILE-NAME = string The name of a file to log to Returns: void Throws: nothing Sets up a file to print debugging messages to. N(sfileNames_debugFileName(sfileName((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys DebugToFilescCs dadS(sTurn on debugging for all modules No arguments Returns: void Throws: nothing Turns on debugging flag for all modules iN(s_debugAllModules(((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys DebugOnAllscCsda|adS(sTurn on debugging for selected modules MODULE-LIST = list(string) Returns: void Throws: nothing Turns on debugging flag for selected modules iN(s_debugAllModuless moduleLists_modulesToDebug(s moduleList((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysDebugOnscCs0tp |tjotd||fndS(sPrint a debug text MODULE = string Name of the module that is printing the debug text TXT = string The text to print as debugging message Returns: void Throws: nothing Prints a debugging text. The text is printed if debugging for the module is turned on, see DebugOnAll and DebugOn. The debug message is printed to stdout, except if debugging has been set to go to a file, see DebugToFile. s%s: %sN(s_debugAllModulessmodules_modulesToDebugs_DebugEmitTextstxt(smodulestxt((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysDebugscCs't|}td|||fdS(sPrint a debug text and a hexdump of a message MODULE = string Name of the module that is printing the debug text TXT = string The text to print as debugging message MSG = string The message to hexdump Returns: void Throws: nothing Prints a debugging text. The text is printed if debugging for the module is turned on, see DebugOnAll and DebugOn. The debug message is printed to stdout, except if debugging has been set to go to a file, see DebugToFile. s %s: %s %sN(s HexDumpFormatsmsgshexMsgs_DebugEmitTextsmodulestxt(smodulestxtsmsgshexMsg((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysDebugHex s cCsfttjo |GHnMy4ttd}|i||i|iWntj o }nXdS(Nsw( s_debugFileNamesNonestxtsopensfswritesflushsclosesIOErrorsinfo(stxtsinfosf((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys_DebugEmitTexts    cCsd}|}d}d}xst|djo_t|djo||||}d}q||||d }|d}|d}qW|SdS(NcCsd}d}xtttt||D]\}}|djo|d}n|dt |}|djp#t |djot |djo|d}q+||}q+Wdt|}|d |}d |}|d |d |SdS( Nsis s%02xiis.is s%04xs: ( s hexStrings ascStringsmapsNonesrangeslensssiscsordsnumFillsaddrs addrString(saddrssscsis hexStringsnumFills addrStrings ascString((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys dump_chars-s  3 isi(s dump_charssstringsremaining_charssaddrsresultslen(sstringsaddrsremaining_charssresults dump_chars((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys_HexDumpFormat,s   sCallbackcBs)tZdZdZdZdZRS(sThis class provides a callback object. Here's how to use it: def MyFunction1(...): pass def MyFunction2(..., arg1, arg2, arg3): pass def MyFunction3(..., arg1, arg2, arg3, kw1=None, kw2=None): pass cb1 = Callback(MyFunction1) cb2 = Callback(MyFunction2, 1, 2, 3) cb3 = Callback(MyFunction3, 1, 2, 3, kw1=4, kw2=5) RegisterCallback(cb1) RegisterCallback(cb2) RegisterCallback(cb3) Any arguments that the invoker uses are tacked on before the first callback-argument, hence the `...' in the function definitions above. This example might clarify: def MyFunction(s1, s2, arg1, arg2): print "s1=%s, s2=%s, arg1=%s, arg2=%s" % (`s1`, `s2`, `arg1`, `arg2`) mycb = Callback(MyFunction, 3, 4) RegisterCallback(mycb) ... #someone calls: cb(1, 2) # This will cause MyFunction to be invoked as MyFuntion(1,2,3,4), # the arguments 1 and 2 tacked on to the front, # coming from the callback invoker, and arguments 3 and 4 # come from the creation of the callback object # Thus, the following will be printed: s1=1, s2=2, arg1=3, arg2=4 cOs||_||_||_dS(N(scallbacksselfsoptArgss namedArgs(sselfscallbacksoptArgss namedArgs((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__init__os  cGsVy!t|i||i|iSWn.tj o nd|iGHnXdS(NsError in VCallback %s(sapplysselfscallbacks extraArgssoptArgss namedArgssKeyboardInterrupts__repr__(sselfs extraArgs((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__call__ts!cCsd|i SdS(Ns(sselfscallback(sself((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__repr__}s(s__name__s __module__s__doc__s__init__s__call__s__repr__(((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pysCallbackJs $  s VCallbackcBs)tZdZdZdZdZRS(sThis class provides a callback object. It is similar to the Callback (see the doc for this class), but is intended to be used in a situation where you have already collected the optional args and the keyword args. Here's an example of when to use this class instead of the Callback class: def DefineRegisterCallback(cbfn, *optArgs, *namedArgs): cb = VCallback(cbfn, optArgs namedArgs) RegisterCallback(cb) ... DefineRegisterCallback(MyFunction, 1, 2) cCs||_||_||_dS(N(scallbacksselfsoptArgss namedArgs(sselfscallbacksoptArgss namedArgs((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__init__s  cGszy!t|i||i|iSWnRtj o n>d|iGHd| GHd|i GHd|i GHnXdS(NsError in VCallback %ss extraArgs=%ss self.optArgs=%ss self.namedArgs=%s(sapplysselfscallbacks extraArgssoptArgss namedArgssKeyboardInterrupts__repr__(sselfs extraArgs((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__call__s!   cCsd|i SdS(Ns(sselfscallback(sself((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys__repr__s(s__name__s __module__s__doc__s__init__s__call__s__repr__(((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys VCallbacks   (sossstringssocketsReadInt1sReadInt2sReadInt4sPackInt1sPackInt2sPackInt4s AlignNodeNamesAlignShortNodeNamesAlignLongNodeNamesGetFullyQualifiedHostNamesgetenvsIndexSeqsNones _logfilenames SetLogFilesLogs_modulesToDebugs_debugAllModuless_debugFileNames DebugToFiles DebugOnAllsDebugOnsDebugsDebugHexs_DebugEmitTexts_HexDumpFormatsCallbacks VCallback(sLogsAlignLongNodeNamesDebugHexs AlignNodeNamesDebugOnsPackInt2sPackInt1sPackInt4sReadInt4sReadInt1sReadInt2s DebugOnAllsstringsDebugs_DebugEmitTexts_HexDumpFormatsgetenvsIndexSeqs VCallbackssocketsCallbacksGetFullyQualifiedHostNamesAlignShortNodeNames SetLogFiles DebugToFilesos((sN/mnt/gmirror/ports/devel/py_otp_interface/work/py_interface-0.93/erl_common.pys?s:                   6