Files

77 lines
2.1 KiB
Python
Raw Permalink Normal View History

2011-04-27 02:45:41 -07:00
#!/usr/bin/env python
2011-03-15 22:18:01 -07:00
'''
This file is part of the PyPhantomJS project.
Copyright (C) 2011 James Roe <roejames12@hotmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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
2011-09-23 04:40:56 -07:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2011-03-15 22:18:01 -07:00
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
2011-09-23 04:40:56 -07:00
along with this program. If not, see <http://www.gnu.org/licenses/>.
2011-03-15 22:18:01 -07:00
'''
# automatically convert Qt types by using api 2
import sip
2011-09-01 16:04:23 -07:00
for item in ('QDate', 'QDateTime', 'QString', 'QTextStream', 'QTime'
'QUrl', 'QVariant'):
sip.setapi(item, 2)
2011-06-03 21:15:59 -07:00
import sys
2011-04-12 01:32:07 -07:00
2011-09-15 17:18:08 -07:00
from PyQt4.QtGui import QApplication, QIcon
2011-06-03 21:15:59 -07:00
2011-07-04 02:37:18 -07:00
from plugincontroller import do_action
# load plugins if running script directly
if __name__ == '__main__':
from plugincontroller import load_plugins
load_plugins()
2011-06-03 21:15:59 -07:00
import resources
from __init__ import __version__
2011-11-27 10:56:12 -08:00
from arguments import parseArgs
2011-04-12 01:32:07 -07:00
from phantom import Phantom
2011-03-15 22:18:01 -07:00
# make keyboard interrupt quit program
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
2011-05-03 16:45:53 -07:00
# output unicode safe text
from utils import SafeStreamFilter
sys.stdout = SafeStreamFilter(sys.stdout)
sys.stderr = SafeStreamFilter(sys.stderr)
2011-05-31 16:23:06 -07:00
2011-12-11 13:07:06 -08:00
def main(arguments):
app = QApplication([sys.argv[0]] + arguments)
2011-03-15 22:18:01 -07:00
app.setWindowIcon(QIcon(':/resources/pyphantomjs-icon.png'))
app.setApplicationName('PyPhantomJS')
app.setOrganizationName('Umaclan Development')
app.setOrganizationDomain('www.umaclan.com')
app.setApplicationVersion(__version__)
2011-03-15 22:18:01 -07:00
2011-12-11 13:07:06 -08:00
args = parseArgs(app, arguments)
phantom = Phantom(app, args)
2011-07-04 02:37:18 -07:00
do_action('Main')
2011-05-31 23:17:50 -07:00
if phantom.execute():
app.exec_()
2011-05-31 16:23:06 -07:00
return phantom.returnValue()
2011-04-27 02:45:41 -07:00
2011-07-04 02:37:18 -07:00
do_action('PyPhantomJS')
2011-05-31 16:23:06 -07:00
2011-04-27 02:45:41 -07:00
if __name__ == '__main__':
2011-12-11 13:07:06 -08:00
sys.exit(main(sys.argv[1:]))