1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * - charScanScript commands
20 * * path for script files in cfg
21 * - charScanScriptNew <description>
22 * - charScanScriptLoad <file_name>
23 * - charScanScriptSave <file_name>
24 * - charScanScriptListFiles
25 * - charScanScriptListLines
26 * - charScanScriptDeleteLine <line_number>
27 * - charScanScriptAddInputFiles <directory> <wildcards>
28 * - charScanScriptAddInfoExtractor <infoExtractorName> [<args>]
29 * - charScanScriptAddFilter <filterName> [<args>]
30 * - charScanScriptAddPreInclude <include_file_name>
31 * - charScanScriptAddPostInclude <include_file_name>
32 * - charScanScriptSetOutputDirectory <directoryName>
33 * - charScanScriptSetDescription <description>
34 * - charScanScriptRun [-s <file_name>] [-o <output_directory>]
35 * - addJobCharScanScript [-s <file_name>] [-o <output_directory>]
36 * - charScanScriptListOutputFiles [<output_directory>]
37 * - charScanScriptListOutputFileContents <file_name> [<output_directory>]
38 * - charScanScriptTestFileList
39 * - charScanScriptTestOutput <test_input_file_path>
40 * - charScanScriptHelp
41 * - path for generated files (from cfg + override) => managed incrementally with directory numbering
42 * - add incremental update systems
43 * - add tables with a column per day ()
44 * - add tables with a column per week (limited number of weeks)
45 * - add tables with a column per month (limited number of months)
49 bool CCharFilterFactory::beginScanJob(const std::vector<std::string>& files, const std::vector<std::string>& filters)
54 NLMISC::CSmartPtr<CCharacterScanJob> job=new CCharacterScanJob;
56 // look after the filters
57 for (uint32 i=0;i<filters.size();++i)
59 // locate the info extractor corresponding to the given name
61 for (j=0;j<_Filters.size();++j)
62 if (filters[i]==_Filters[j]->getName())
65 // if none found then warn and skip passed
66 if(j>=_Filters.size())
68 nlwarning("Unknown info extractor: %s",filters[i].c_str());
73 // add the info extractor to the new job
74 job->addFilter(_Filters[j]);
77 // look after the files
80 // add the job to the job manager
82 CJobManager::getInstance()->addJob(&*job);
88 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
92 #include "nel/misc/path.h"
93 #include "nel/misc/command.h"
94 #include "nel/misc/variable.h"
95 #include "nel/misc/algo.h"
96 #include "game_share/persistent_data.h"
98 #include "character.h"
99 #include "job_manager.h"
100 #include "char_info_extractor_factory.h"
103 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
108 using namespace NLMISC
;
110 //-----------------------------------------------------------------------------
112 //-----------------------------------------------------------------------------
114 CVariable
<string
> SourceDirectory("variables", "SourceDirectory", "Directory we scan for files", string("."), 0, true);
117 //-----------------------------------------------------------------------------
118 // Commands - misc character related
119 //-----------------------------------------------------------------------------
121 NLMISC_COMMAND(listCharNames
,"display the names of the characters int he listed save files","<input file name>")
123 if (args
.size()!=1 && args
.size()!=0)
126 std::string wildcard
="pdr_account*";
130 std::vector
<std::string
> files
;
131 NLMISC::CPath::getPathContent(SourceDirectory
.get().c_str(),false,false,true,files
);
132 for (uint32 i
=(uint32
)files
.size();i
--;)
134 if (!NLMISC::testWildCard(NLMISC::CFile::getFilename(files
[i
]),wildcard
))
136 files
[i
]=files
.back();
140 std::sort(files
.begin(),files
.end());
141 for (uint32 i
=0;i
<files
.size();++i
)
143 static CPersistentDataRecord pdr
;
145 pdr
.readFromFile(files
[i
]);
147 CStatsScanCharacter c
;
150 log
.displayNL("%-40s Name: %s ", files
[i
].c_str(), c
.EntityBase
._Name
.c_str());
156 //-----------------------------------------------------------------------------
157 // Commands - charScanner
158 //-----------------------------------------------------------------------------
160 NLMISC_COMMAND(listCharInfoExtractors
,"display the list of info extractors that exist for characters","")
165 CCharInfoExtractorFactory::getInstance()->displayInfoExtractorList(&log
);
170 //-----------------------------------------------------------------------------
171 // Commands - jobsManager
172 //-----------------------------------------------------------------------------
174 NLMISC_COMMAND(jobsPause
,"pause execution of jobs","")
179 CJobManager::getInstance()->pause();
184 NLMISC_COMMAND(jobsResume
,"resume execution of jobs","")
189 CJobManager::getInstance()->resume();
194 NLMISC_COMMAND(jobsPromote
,"pause execution of jobs","<jobId>")
200 NLMISC::fromString(args
[0], idx
);
202 if ( (idx
==0 && args
[0]!="0") )
204 nlwarning("Argument is not a valid job id - should be a number");
208 CJobManager::getInstance()->promoteJob(idx
);
209 CJobManager::getInstance()->listJobs(&log
);
214 NLMISC_COMMAND(JobUpdatesPerUpdate
,"set or display the number of job updates per service update","[<count>]")
222 NLMISC::fromString(args
[0], count
);
224 if ( (count
==0 && args
[0]!="0") )
226 nlwarning("Argument is not a valid number");
229 CJobManager::getInstance()->setJobUpdatesPerUpdate(count
);
232 nlinfo("JobUpdatesPerUpdate %d",CJobManager::getInstance()->getJobUpdatesPerUpdate());
237 NLMISC_COMMAND(jobsStatus
,"display the status of the job manager","")
242 log
.displayNL("%s",CJobManager::getInstance()->getStatus().c_str());
247 NLMISC_COMMAND(jobsList
,"display the list of unfinished jobs","")
252 CJobManager::getInstance()->listJobs(&log
);
257 NLMISC_COMMAND(jobsListAll
,"display the list of all jobs (unfinished jobs are marked with a '*')","")
262 CJobManager::getInstance()->listJobHistory(&log
);
267 NLMISC_COMMAND(jobsDisplayDetails
,"display detailed info for the current job (or a given job)","[<job id>]")
272 CJobManager::getInstance()->displayCurrentJob(&log
);
278 NLMISC::fromString(args
[0], idx
);
280 if ( (idx
==0 && args
[0]!="0") )
282 nlwarning("Argument is not a valid job id - should be a number");
285 CJobManager::getInstance()->displayJob(idx
,&log
);
297 //-----------------------------------------------------------------------------
298 // Commands - charScanScript
299 //-----------------------------------------------------------------------------
302 //-----------------------------------------------------------------------------