Commit 038b11273a956fd19bbd93b5297283305fa6d1b9

Authored by Wesnydy Ribeiro
1 parent 78f71b6a
Exists in master and in 1 other branch devel

Atualização e correção de bugs

main.cpp
... ... @@ -39,6 +39,7 @@ void serviceText(string path_text, int language, int background, string id, int
39 39 void serviceRECWithoutMixing(int service, string path_video, int background, string id, int mode);
40 40 void serviceTest(int position, int size, int background);
41 41  
  42 +void help();
42 43 void hasFailed();
43 44 void hasInvalid();
44 45 void fail(string msg);
... ... @@ -73,7 +74,6 @@ int main(int argc, char* argv[]) {
73 74 try{
74 75 parser->readArgs(argv, argc);
75 76 }catch(lavidlib::RuntimeException &ex){
76   - PRINTL(util::_ERROR, "%s\n", ex.getMessage().c_str());
77 77 exit(1);
78 78 }
79 79  
... ... @@ -145,15 +145,19 @@ int main(int argc, char* argv[]) {
145 145 serviceREC(service, input, 0, 0, background, id, mode);//como service != 2 então não há mixagem
146 146 break;
147 147  
148   - case 7:
  148 + case 7: // serviço de teste
149 149 position = parser->getPosition();
150 150 size = parser->getSize();
151 151 background = parser->getBackground();
152 152 serviceTest(position, size, background);
153 153 break;
154 154  
  155 + case 8: //ajuda
  156 + help();
  157 + break;
  158 +
155 159 default:
156   - PRINTL(util::_INFO, "Opção de serviço não reconhecida!\n");
  160 + PRINTL(util::_ERROR, "Opção de serviço não reconhecida!\n");
157 161 hasInvalid();
158 162 }
159 163  
... ... @@ -326,4 +330,28 @@ void setPathContents(int mode, string id){
326 330 exit(127);
327 331 }
328 332 system(command.c_str());
  333 +}
  334 +
  335 +void help()
  336 +{
  337 + std::cout << std::endl
  338 + << "Usage Summary: vlibras [Service_option] filepath [Options] --id [name] --mode [devel,prod]"
  339 + << "\n\nService_option:"
  340 + << "\n\tVideo with Subtitles -V, --video [filePath] -S, --subtitle [filePath]"
  341 + << "\n\tVideo Recognize -V, --video [filePath]"
  342 + << "\n\tAudio Recognize -A, --audio [filepath]"
  343 + << "\n\tText -T, --text [filePath]"
  344 + << "\n\tSubtitles only -S, --subtitle [filePath]"
  345 + << "\n\nOptions:"
  346 + << "\n\t-l, --language [portugues,libras]"
  347 + << "\n\t-b, --background [opaque,transp]"
  348 + << "\n\t-r, --resolution [small,medium,large]"
  349 + << "\n\t-p, --position [top_left,top_right,bottom_left,bottom_right]"
  350 + << "\n\t-m, --mode [devel,prod]"
  351 + << "\n\t-v, --loglevel [quiet,error,warning,info,debug]"
  352 + << "\n\t--id [name] Relative to the unique ID on the Database."
  353 + << "\n\t--no-mixer Disables mixing with the original video."
  354 + << "\n\nSee man vlibras for detailed descriptions."
  355 + << std::endl;
  356 + exit(0);
329 357 }
330 358 \ No newline at end of file
... ...
servico/src/serviceWindowGenerationFromRec.cpp
... ... @@ -58,8 +58,19 @@ void ServiceWindowGenerationFromRec::setPathContents(){
58 58 switch(exec_mode) {
59 59 case DEVELOPER:
60 60 {
61   - this->path_contents = (char*) PATH_DEVEL_CONTENTS;
62   - this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  61 + char* vStorage;
  62 + char* vUploads;
  63 + vStorage = getenv("VLSTORAGE");
  64 + vUploads = getenv("VLUPLOADS");
  65 +
  66 + if(vStorage != NULL && vUploads != NULL){
  67 + this->path_contents = vStorage;
  68 + this->path_uploads = vUploads;
  69 + PRINTL(util::_DEBUG, "Paths definidos pelo desenvolvedor:\n %s\n%s", path_contents, path_uploads);
  70 + }else{
  71 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  72 + this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  73 + }
63 74 rec->setPathAudioContents(path_uploads);
64 75 }break;
65 76  
... ...
servico/src/serviceWindowGenerationFromSRT.cpp
... ... @@ -61,8 +61,19 @@ void ServiceWindowGenerationFromSRT::setPathContents() {
61 61 switch(exec_mode) {
62 62 case DEVELOPER:
63 63 {
64   - this->path_contents = (char*) PATH_DEVEL_CONTENTS;
65   - this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  64 + char* vStorage;
  65 + char* vUploads;
  66 + vStorage = getenv("VLSTORAGE");
  67 + vUploads = getenv("VLUPLOADS");
  68 +
  69 + if(vStorage != NULL && vUploads != NULL){
  70 + this->path_contents = vStorage;
  71 + this->path_uploads = vUploads;
  72 + PRINTL(util::_DEBUG, "Paths definidos pelo desenvolvedor:\n %s\n%s", path_contents, path_uploads);
  73 + }else{
  74 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  75 + this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  76 + }
66 77 }break;
67 78  
68 79 case PRODUCTION:
... ...
servico/src/serviceWindowGenerationFromText.cpp
... ... @@ -33,7 +33,14 @@ void ServiceWindowGenerationFromText::setPathContents() {
33 33 switch(exec_mode) {
34 34 case DEVELOPER:
35 35 {
36   - this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  36 + char* vStorage;
  37 + vStorage = getenv("VLSTORAGE");
  38 + if(vStorage != NULL){
  39 + this->path_contents = vStorage;
  40 + PRINTL(util::_DEBUG, "Path definido pelo desenvolvedor:\n%s", path_contents);
  41 + }else{
  42 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  43 + }
37 44 }break;
38 45  
39 46 case PRODUCTION:
... ...
util/src/argParser.cpp
... ... @@ -32,16 +32,20 @@ void ArgParser::readArgs(char** argv, int argc)
32 32 switch (opt)
33 33 {
34 34 case 'A':
35   - if(argc < 9)
36   - throw lavidlib::RuntimeException("Insuficient arguments. Try again");
  35 + if(argc < 9){
  36 + printf("Insuficient arguments. Try again\n");
  37 + throw lavidlib::RuntimeException();
  38 + }
37 39  
38 40 globalArgs.service = _REC_AUDIO;
39 41 globalArgs.input = optarg;
40 42 break;
41 43  
42 44 case 'S':
43   - if(argc < 11 || (globalArgs.service == _REC_VIDEO && argc < 17))
44   - throw lavidlib::RuntimeException("Insuficient arguments. Try again");
  45 + if(argc < 11 || (globalArgs.service == _REC_VIDEO && argc < 17)){
  46 + printf("Insuficient arguments. Try again\n");
  47 + throw lavidlib::RuntimeException();
  48 + }
45 49  
46 50 if(globalArgs.service == _REC_VIDEO){ // ativa o serviço de vídeo e legendas
47 51 globalArgs.service = _VIDEO_WITH_SRT;
... ... @@ -53,16 +57,20 @@ void ArgParser::readArgs(char** argv, int argc)
53 57 break;
54 58  
55 59 case 'T':
56   - if(argc < 11)
57   - throw lavidlib::RuntimeException("Insuficient arguments. Try again");
  60 + if(argc < 11){
  61 + printf("Insuficient arguments. Try again\n");
  62 + throw lavidlib::RuntimeException();
  63 + }
58 64  
59 65 globalArgs.service = _TEXT;
60 66 globalArgs.input = optarg;
61 67 break;
62 68  
63 69 case 'V':
64   - if(argc < 13 || ((globalArgs.service == _ONLY_SRT && argc < 17)))
65   - throw lavidlib::RuntimeException("Insuficient arguments. Try again");
  70 + if(argc < 13 || ((globalArgs.service == _ONLY_SRT && argc < 17))){
  71 + printf("Insuficient arguments. Try again\n");
  72 + throw lavidlib::RuntimeException();
  73 + }
66 74  
67 75 if(globalArgs.service == _ONLY_SRT){ // ativa o serviço de vídeo e legendas
68 76 globalArgs.service = _VIDEO_WITH_SRT;
... ... @@ -114,7 +122,7 @@ void ArgParser::readArgs(char** argv, int argc)
114 122 break;
115 123  
116 124 case 'h':
117   - help();
  125 + globalArgs.service = _HELP;
118 126 break;
119 127 case '?':
120 128 /* o getopt já mostra o erro no terminal!*/
... ... @@ -140,30 +148,6 @@ void ArgParser::readArgs(char** argv, int argc)
140 148 }
141 149 }
142 150  
143   -void ArgParser::help()
144   -{
145   - std::cout << std::endl
146   - << "Usage Summary: vlibras [Service_option] filepath [Options] --id [name] --mode [devel,prod]"
147   - << "\n\nService_option:"
148   - << "\n\tVideo with Subtitles -V, --video [filePath] -S, --subtitle [filePath]"
149   - << "\n\tVideo Recognize -V, --video [filePath]"
150   - << "\n\tAudio Recognize -A, --audio [filepath]"
151   - << "\n\tText -T, --text [filePath]"
152   - << "\n\tSubtitles only -S, --subtitle [filePath]"
153   - << "\n\nOptions:"
154   - << "\n\t-l, --language [portugues,libras]"
155   - << "\n\t-b, --background [opaque,transp]"
156   - << "\n\t-r, --resolution [small,medium,large]"
157   - << "\n\t-p, --position [top_left,top_right,bottom_left,bottom_right]"
158   - << "\n\t-m, --mode [devel,prod]"
159   - << "\n\t-v, --loglevel [quiet,error,warning,info,debug]"
160   - << "\n\t--id [name] Relative to the unique ID on the Database."
161   - << "\n\t--no-mixer Disables mixing with the original video."
162   - << "\n\nSee man vlibras for detailed descriptions."
163   - << std::endl;
164   - throw lavidlib::RuntimeException(); //para nao iniciar o vlibras
165   -}
166   -
167 151 util::logLevel ArgParser::logFromString(const string& level)
168 152 {
169 153 if(level == "quiet")
... ...
util/src/include/argParser.h
... ... @@ -34,7 +34,7 @@ public:
34 34 util::logLevel getLog();
35 35  
36 36 private:
37   - enum Services { _VIDEO_WITH_SRT = 1, _REC_VIDEO, _TEXT, _ONLY_SRT, _REC_AUDIO, _WITHOUT_MIXER, _TESTER };
  37 + enum Services { _VIDEO_WITH_SRT = 1, _REC_VIDEO, _TEXT, _ONLY_SRT, _REC_AUDIO, _WITHOUT_MIXER, _TESTER , _HELP};
38 38 enum Languages { _PORTUGUESE = 1, _GLOSA };
39 39 enum Positions { _TOP_LEFT = 1, _TOP_RIGHT, _BOTTOM_RIGHT, _BOTTOM_LEFT };
40 40 enum Resolution { _SMALL = 1, _MEDIUM, _LARGE };
... ... @@ -56,8 +56,6 @@ private:
56 56 util::logLevel l_level;
57 57 }globalArgs;
58 58  
59   - void help();
60   - void loadDefaults();
61 59 void returnErr(const string& option);
62 60 Languages languageFromString(const string& language);
63 61 Positions positionFromString(const string& position);
... ...