Porkchop is 'n eenvoudige HTTP-gebaseerde stelsel inligting bediener geskryf in Python nbsp &;. Jy skryf plugins vir dit en dit reageer met die data wat gebaseer is op jou versoek.
Hier is 'n voorbeeld:
Scott @ Beatbox: ~% krul http: // localhost: 5000 / cpuinfo
/ Cpuinfo / processor2 / FPU ja
/ Cpuinfo / processor2 / f00f_bug geen
/ Cpuinfo / processor2 / cache_alignment 64
/ Cpuinfo / processor2 / vendor_id AuthenticAMD
/ Cpuinfo / processor2 / vlae FPU
/ Cpuinfo / processor2 / bogomips 6384
/ Cpuinfo / processor2 / hlt_bug geen
/ Cpuinfo / processor2 / apicid 2
/ Cpuinfo / processor2 / fpu_exception ja
/ Cpuinfo / processor2 / versterking 3
/ Cpuinfo / processor2 / wp ja
/ Cpuinfo / processor2 / broers en susters 4
/ Cpuinfo / processor2 / model 4
/ Cpuinfo / processor2 / coma_bug geen
/ Cpuinfo / processor2 / fdiv_bug geen
/ Cpuinfo / processor3 / FPU ja
/ Cpuinfo / processor3 / f00f_bug geen
/ Cpuinfo / processor3 / cache_alignment 64
/ Cpuinfo / processor3 / vendor_id AuthenticAMD
/ Cpuinfo / processor3 / vlae FPU
/ Cpuinfo / processor3 / bogomips 6384
/ Cpuinfo / processor3 / hlt_bug geen
/ Cpuinfo / processor3 / apicid 3
/ Cpuinfo / processor3 / fpu_exception ja
/ Cpuinfo / processor3 / versterking 3
/ Cpuinfo / processor3 / wp ja
/ Cpuinfo / processor3 / broers en susters 4
/ Cpuinfo / processor3 / model 4
/ Cpuinfo / processor3 / coma_bug geen
/ Cpuinfo / processor3 / fdiv_bug geen
[Snip]
/ Tyd 1311387215
Scott @ Beatbox: ~%
Dit kan ook reageer met into via .json lêer uitbreiding of die opstel van die Aanvaar: aansoek / into kop.
Scott @ Beatbox: ~% krul http: // localhost: 5000 / cpuinfo.json
{"Cpuinfo": {"processor2": {"FPU": "ja", "f00f_bug": "Nee", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "vlae": "FPU" "bogomips": "6384", "hlt_bug": "Nee", "apicid": "2", "fpu_exception": "ja", "versterking": "3", "Die WP": "ja", " broers en susters ":" 4 "," model ":" 4 "," coma_bug ":" Nee "," fdiv_bug ":" nee "}," processor3 ": {" FPU ":" ja "," f00f_bug ":" nee "," cache_alignment ":" 64 "," vendor_id ":" AuthenticAMD "," vlae ":" FPU "," bogomips ":" 6384 "," hlt_bug ":" Nee "," apicid ":" 3 " "fpu_exception": "ja", "versterking": "3", "Die WP": "ja", "broers en susters": "4", "model": "4", "coma_bug": "Nee", " fdiv_bug ":" nee "}," processor0 ": {" FPU ":" ja "," f00f_bug ":" Nee "," cache_alignment ":" 64 "," vendor_id ":" AuthenticAMD "," vlae ":" FPU "," bogomips ":" 6382 "," hlt_bug ":" Nee "," apicid ":" 0 "," fpu_exception ":" ja "," versterking ":" 3 "," Die WP ":" ja " , "broers en susters": "4", "model": "4", "coma_bug": "Nee", "fdiv_bug": "nee"}, "processor1": {"FPU": "ja", "f00f_bug" : "Nee", "cache_alignment": "64", "vendor_id": "AuthenticAMD", "vlae": "FPU", "bogomips": "6384", "hlt_bug": "Nee", "apicid": " 1 "," fpu_exception ":" ja "," versterking ":" 3 "," Die WP ":" ja "," broers en susters ":" 4 "," model ":" 4 "," coma_bug ":" nee " "fdiv_bug": "nee"}}, "tyd": "1311389934"}
Scott @ Beatbox: ~%
Installasie
PIP installeer porkchop
of
python setup.py installeer
Skryf proppe
Dit is redelik maklik om 'n nuwe prop te skryf. Hulle is net Python modules met 'n paar algemene kenmerke:
- 'N plugin moet oorerf porkchop.plugin.PorkchopPlugin.
- Die plugin se klas moet bijvoegsel met Plugin. Die werklike lêer naam in die plugin gids moet ook ooreenstem met die voorvoegsel. Byvoorbeeld, sou FooPlugin in die lêer foo.py wees
- Die plugin se klas moet 'n metode genoem get_data dat die opbrengste van 'n woordeboek van die inligting te vertoon word, bevat.
By verstek, 'n plugin se get_data metode sal slegs genoem word as die data is meer as 60 sekondes oud. Dit kan verander word op 'n per-plugin basis deur die oprigting van self.refresh in die klas se ___init___ metode.
. Hierdie modules kan in 'n gids wat jy kies geplaas word, en gelaai deur verby die d opsie om porkchop
Vereistes :
- Python
Kommentaar nie gevind