chiark / gitweb /
Merge branch 'twomack'
[ypp-sc-tools.db-test.git] / pctb / README
1 Overview
2 --------
3
4 This tool can:
5   - screenscrape the commodities trading screen
6   - produce the results as a tab separated values file
7   - upload the results to PCTB
8
9 To run it, change to this directory, type `make', and then:
10   ./ypp-commodities --tsv >commods.tsv
11 or
12   ./ypp-commodities --upload
13
14 While it is capturing the screenshots, do not move the mouse or use
15 the keyboard.  Keyboard focus must stay in the YPP client window.
16
17 You will probably need to turn off `Use antialiased font' in the YPP
18 client.  This is in the Ye panel, Options, tab `General'.
19
20 Command-line options
21 --------------------
22
23 Setting the operation mode:
24   --find-window-only       Just check that we can find the YPP client window.
25   --screenshot-only        Page through and take screenshots, do not OCR
26   --analyse-only | --same  Process previously taken screenshots
27   --everything (default)   Take screenshots and process them
28
29 Options to vary the processing:
30   --single-page         One screenful, no paging - results will be incomplete
31   --quiet               Suppress progress messages
32   --screenshot-file F   Store or read screenshots in F rather than #pages#.pnm
33   --window-id ID        Specified X window is the YPP client - do not search
34   --edit-charset        Enable character set editing.  See README.dictionary.
35   --find-island         Find and print the ocean and island.  Suppresses OCR
36                          and output unless used with result processing option.
37   --test-servers        Set default servers to be the test servers, not
38                          the real live ones (doesn't affect explicit settings).
39
40 Controlling what happens to the results - only one at a time:
41   --upload (default) Upload to the PCTB server
42   --tsv              Print data as clean tab-separated-values file
43   --raw-tsv          Dump the raw (not deduped, unsorted) OCR'd data
44   --best-prices      Print best buy and sell price for each commodity
45   --arbitrage        Print arbitrage opportunities
46
47 Privacy options, which control conversations with the dictionary server:
48   --dict-local-only  *  Do not talk to the server even to fetch new dictionary.
49   --dict-read-only   *  Only fetch new dictionary, do not submit new entries.
50   --dict-anon           Don't quote pirate name if submitting entries.
51   --dict-submit         Submit entries quoting my pirate name.  (default)
52 Please do not use options marked * with --upload.  See README.privacy.
53
54 Options to override which servers we talk to:
55   --pctb-server HOST|URL  Talk to the PCTB server at HOST or URL.
56   --dict-submit-url URL   Submit dictionary entries with HTTP POST under URL.
57   --dict-update-from SRC  Fetch updated master dictionary with rsync from SRC.
58 Or set the environment variables YPPSC_PCTB{_PCTB, _DICT_UPDATE, _DICT_SUBMIT}
59
60
61 Files we use and update
62 -----------------------
63
64 The program reads and writes the following files:
65
66  * #pages#.pnm
67
68    Contains one or more images (as raw ppms, end-to-end) which are the
69    screenshots taken in the last run.  This is (over)written whenever
70    we take screenshots from the YPP client.  You can reprocess an
71    existing set of screenshots with the --same (aka --analyse-only)
72    option; in that case we just read the screenshots file.
73
74    You can specify a different file with --screenshot-file.
75
76    If you want to display the contents of this file, `display' can do
77    it.  Don't try `display vid:#pages#.pnm' as this will consume
78    truly stupendous quantities of RAM - it wedged my laptop.
79
80  * #master-newcommods#.txt #local-newcommods#.txt
81
82    Dictionary of newly introduced commodities.  When a new commodity
83    appears in Puzzle Pirates, the PCTB server operators need to add it
84    to their database for us to be able to upload data about it.
85
86    It can sometimes take a few days to do this.  In the meantime, it
87    is possible to upload partial data - data just omitting that
88    commodity.  This is controlled by these files: they list
89    commodities which should be automatically ignored if the PCTB
90    server doesn't know about them.  The master file is downloaded and
91    updated automatically from my server.  You may create the local
92    file yourself.  The format is simple: one commodity per line.
93
94    Unrecognised commodities can also be due to OCR failure so
95    double-check what you're doing before overriding the uploader by
96    telling it to ignore an unrecognised commodity.
97
98  * #master-char*#.txt  #local-char*#.txt
99    #master-pixmap#.txt #local-pixmap#.txt
100
101    Character set and image dictionaries.  For the semantics of the
102    char* files README.charset.  There is not currently any accurate
103    documentation of this dictionary format.
104
105    #master-*#.txt contain the centrally defined and approved data.
106    They are downloaded automatically from the SC PCTB server and
107    updated each run.  You can safely delete this file, if everything
108    is online, if you want to fetch a fresh copy.
109
110    #local-*#.txt are a local copy of your submissions, so that they
111    will be used by your client pending approval by me.  You can delete
112    this file if you think you may have made a mistake.
113
114    See README.privacy for details of the communications with the SC
115    server about the contents of these dictionaries.
116
117  * #commodmap#.tsv
118
119    Map from commodity names to the numbers required by the PCTB
120    server.  This is fetched and updated automatically as necessary.
121    It can safely be deleted as it will then be refetched.
122
123  * #upload-1#.html #upload-2#.html
124
125    We screenscrape the pages from the PCTB upload server.  The actual
126    HTML returned from the upload server is left in these dropping
127    files for debugging etc.
128
129  * <file>.new
130
131    When any of these tools overwrite one of the persistent dictionary
132    files, they temporarily write to <file>.new.
133
134 These files are all in the current working directory.  There is not
135 yet any feature to have them be somewhere else.  The helper programs
136   dictionary-manager
137   commod-results-processor
138 must (currently) also be in the current directory.
139
140 Future versions may have more helpers and more data files.
141
142
143 Installation requirements
144 -------------------------
145
146 This program has quite a few dependencies:
147                                                         Package (Debian etch)
148
149  - For building, C compiler and build environment       build-essential
150  - pnm library, including dev files for building        libnetpbm10-dev
151  - pnm command line utilities for image manipulation    netpbm
152  - X11 libraries, including dev files for building      libx11-dev
153  - XTEST library, including dev files for building      libxtst-dev
154  - Perl-compatible regexp library, including dev files  libpcre3-dev
155  - Tk interpreter /usr/bin/wish                         tk8.4
156  - Perl module XML::Parser                              libxml-parser-perl
157  - Perl module JSON::Parser                             libjson-perl
158  - XTEST extension in the X server                      (part of X package)
159  - Perl interpreter and basic modules                   perl (usu.installed)
160
161 On other Linux distros the packages may have different names, but
162 these should be roughly right for Debian and its derivatives.
163
164
165 Reporting problems
166 ------------------
167
168 If you need to report a bug, for example an inability to recognise,
169 please be sure to remember the exact error message and circumstances.
170 Also, for recognition problems there will probably be a very useful
171 screenshot file called `#pages#.pnm'.  This is likely to be very large
172 so don't just email it to me, but if you can put it up on a webpage
173 for me to download that will help.  At least keep a copy of it.
174
175 If the problem is a failure to cope with some particular YPP client
176 display and is reproducible, try running:
177    ./ypp-commodities --raw-tsv --single-page
178 If this reproduces the problem, please email me the screenshot file
179 #pages#.pnm, which will consist only of the single screen, plus the
180 error messasge.  I'll then be able to understand what's wrong,
181 hopefully.
182
183
184 Privacy
185 -------
186
187 The main purpose of this program is to connect to the PCTB server and
188 upload data.  It will do that if you run it with --upload.
189
190 This program will also, by default, talk to the dictionary server I
191 have set up: to download updated image dictionaries, and to upload new
192 dictionary entries which you create with the PCTB client dictionary
193 GUI.  This feature is mentioned in and controllable in the GUI itself,
194 so it won't happen without you knowing about it.
195
196 The uploads will by default mention your ocean and pirate name; if you
197 don't want that, pass the --dict-anon option, or untick the box in the
198 GUI.
199
200 See README.privacy for full details.
201
202
203
204  - Ian Jackson
205    ijackson@chiark.greenend.org.uk
206    Aristarchus on the Midnight ocean