-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves the main function to 'coalib.coala' module to separate functionality from command line invocation. To support invocations for all platforms (Windows and Linux), this commit creates both files, 'coala' and 'coala.py'. These only point to the main function in 'coalib.coala'. References #196.
- Loading branch information
Makman2
committed
May 15, 2015
1 parent
0576226
commit 27d7537
Showing
4 changed files
with
105 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published by the | ||
# Free Software Foundation, either version 3 of the License, or (at your | ||
# option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from coalib.coala import main | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License as published by the | ||
# Free Software Foundation, either version 3 of the License, or (at your | ||
# option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import sys | ||
from coalib.output.ClosableObject import ClosableObject | ||
|
||
from coalib.output.printers.ConsolePrinter import ConsolePrinter | ||
from coalib.misc.StringConstants import StringConstants | ||
from coalib.processes.SectionExecutor import SectionExecutor | ||
from coalib.settings.SectionManager import SectionManager | ||
|
||
from coalib.misc.i18n import _ | ||
|
||
|
||
def main(): | ||
log_printer = None | ||
interactor = None | ||
exitcode = 0 | ||
try: | ||
did_nothing = True | ||
yielded_results = False | ||
sections, local_bears, global_bears, targets, interactor, log_printer \ | ||
= SectionManager().run() | ||
for section_name in sections: | ||
section = sections[section_name] | ||
if not section.is_enabled(targets): | ||
continue | ||
|
||
yielded_results = yielded_results or SectionExecutor( | ||
section=section, | ||
global_bear_list=global_bears[section_name], | ||
local_bear_list=local_bears[section_name], | ||
interactor=interactor, | ||
log_printer=log_printer).run()[0] | ||
did_nothing = False | ||
|
||
if did_nothing: | ||
interactor.did_nothing() | ||
|
||
if yielded_results: | ||
exitcode = 1 | ||
except KeyboardInterrupt: # Ctrl+C | ||
print(_("Program terminated by user.")) | ||
exitcode = 130 | ||
except EOFError: # Ctrl+D | ||
print(_("Found EOF. Exiting gracefully.")) | ||
except SystemExit as e: | ||
exitcode = e.code | ||
except: | ||
exception = sys.exc_info()[1] | ||
UNKNOWN_ERROR = _("An unknown error occurred.") + " " + \ | ||
StringConstants.THIS_IS_A_BUG | ||
DESCRIPTION = _("During execution of coala an exception was raised. " | ||
"This should never happen. When asked for, the " | ||
"following information may help investigating:") | ||
|
||
if log_printer is None: | ||
log_printer = ConsolePrinter() | ||
|
||
log_printer.log_exception(UNKNOWN_ERROR + " " + DESCRIPTION, | ||
exception) | ||
exitcode = 255 | ||
|
||
if log_printer is not None and isinstance(log_printer, ClosableObject): | ||
log_printer.close() | ||
if interactor is not None and isinstance(interactor, ClosableObject): | ||
interactor.close() | ||
|
||
exit(exitcode) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27d7537
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack