[Kstars-devel] [kstars] kstars: Fix some issues with supernova and remove dependency on pyKDE4.
Jasem Mutlaq
mutlaqja at ikarustech.com
Wed Feb 18 18:27:44 UTC 2015
Git commit e9f1b544eda238c068fbbbbf612f291c734ea5aa by Jasem Mutlaq.
Committed on 18/02/2015 at 18:26.
Pushed by mutlaqja into branch 'master'.
Fix some issues with supernova and remove dependency on pyKDE4.
CCMAIL:kstars-devel at kde.org
M +6 -3 kstars/data/scripts/supernova_updates_parser.py
M +2 -0 kstars/dialogs/detaildialog.cpp
M +1 -0 kstars/dialogs/finddialog.cpp
M +9 -6 kstars/skycomponents/supernovaecomponent.cpp
http://commits.kde.org/kstars/e9f1b544eda238c068fbbbbf612f291c734ea5aa
diff --git a/kstars/data/scripts/supernova_updates_parser.py b/kstars/data/scripts/supernova_updates_parser.py
index 552e428..2da531c 100644
--- a/kstars/data/scripts/supernova_updates_parser.py
+++ b/kstars/data/scripts/supernova_updates_parser.py
@@ -19,11 +19,11 @@
### This page gives details on supernovae that have occurred since the start of 2010.
#!/usr/bin/env python
+import sys
import re
from urllib import urlopen
import os
import difflib
-from PyKDE4.kdecore import KStandardDirs
def parse( line ) :
parsed = toCSV(re.sub('<.*?>','',line))
@@ -46,7 +46,10 @@ sock.close()
found = False
firstLine = True
-output = open(KStandardDirs().locateLocal('data','kstars/supernovae.dat'),'w')
+output_file=sys.argv[1]
+#print "Output file is " + output_file
+
+output = open(output_file,'w')
for i in pageLines:
if(found):
@@ -65,7 +68,7 @@ for i in pageLines:
p = re.compile("<pre>")
m = p.search(i)
if m:
- print "found!!"+i
+ #print "found!!"+i
firstLine=True
found = True
diff --git a/kstars/dialogs/detaildialog.cpp b/kstars/dialogs/detaildialog.cpp
index 1e07fe2..4e82143 100644
--- a/kstars/dialogs/detaildialog.cpp
+++ b/kstars/dialogs/detaildialog.cpp
@@ -247,6 +247,8 @@ void DetailDialog::createGeneralTab()
case SkyObject::SUPERNOVA:
sup=(Supernova *)selectedObject;
+ objecttyp = xi18n("Supernova");
+
Data->Names->setText(sup->name());
Data->Magnitude->setText( xi18nc( "number in magnitudes", "%1 mag" ,
diff --git a/kstars/dialogs/finddialog.cpp b/kstars/dialogs/finddialog.cpp
index 1fc8843..077de68 100644
--- a/kstars/dialogs/finddialog.cpp
+++ b/kstars/dialogs/finddialog.cpp
@@ -215,6 +215,7 @@ void FindDialog::filterByType() {
break;
case 11: //Supernovae
fModel->setStringList( data->skyComposite()->objectNames( SkyObject::SUPERNOVA ) );
+ break;
case 12: //Satellites
fModel->setStringList( data->skyComposite()->objectNames( SkyObject::SATELLITE ) );
break;
diff --git a/kstars/skycomponents/supernovaecomponent.cpp b/kstars/skycomponents/supernovaecomponent.cpp
index 2a4d258..7ae7719 100644
--- a/kstars/skycomponents/supernovaecomponent.cpp
+++ b/kstars/skycomponents/supernovaecomponent.cpp
@@ -93,7 +93,7 @@ void SupernovaeComponent::loadData()
if(row_content["serialNo"].toString() == "Null")
continue;
- serialNo = row_content["serialNo"].toString();
+ serialNo = row_content["serialNo"].toString().trimmed();
hostGalaxy = row_content["hostGalaxy"].toString();
date = row_content["date"].toString();
ra = dms(row_content["ra"].toString(), false);
@@ -206,11 +206,11 @@ void SupernovaeComponent::notifyNewSupernovae()
if (sup->getMagnitude() > float(Options::magnitudeLimitAlertSupernovae()))
{
- qDebug()<<"Not Bright enough to be notified";
+ //qDebug()<<"Not Bright enough to be notified";
continue;
}
- qDebug()<<"Bright enough to be notified";
+ //qDebug()<<"Bright enough to be notified";
latestList.append(so);
}
if (!latestList.empty())
@@ -226,11 +226,14 @@ void SupernovaeComponent::notifyNewSupernovae()
void SupernovaeComponent::slotTriggerDataFileUpdate()
{
+ QString output = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "supernovae.dat";
QString filename= QStandardPaths::locate(QStandardPaths::DataLocation, "scripts/supernova_updates_parser.py") ;
- qDebug()<<filename;
+ QStringList args;
+ args << filename << output;
+ //qDebug()<<filename;
m_Parser = new QProcess;
connect( m_Parser, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( slotDataFileUpdateFinished( int, QProcess::ExitStatus ) ) );
- m_Parser->start("python2", QStringList( filename ));
+ m_Parser->start("python", args);
}
void SupernovaeComponent::slotDataFileUpdateFinished( int exitCode, QProcess::ExitStatus exitStatus )
@@ -255,7 +258,7 @@ void SupernovaeComponent::slotDataFileUpdateFinished( int exitCode, QProcess::Ex
// FIXME: There should be a better way to check if KStars is fully initialized. Maybe we should have a static boolean in the KStars class. --asimha
}
else {
- qDebug()<<"HERE";
+ //qDebug()<<"HERE";
latest.clear();
loadData();
notifyNewSupernovae();
More information about the Kstars-devel
mailing list