Beispiel #1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.action_system_quit.triggered.connect(self.on_exit)
        self.action_system_restart.triggered.connect(self.on_restart)
        self.action_system_start.triggered.connect(self.on_start)
        self.action_cmd.triggered.connect(self.show_cmd)
        self.action_file.triggered.connect(self.show_file)
        self.action_process.triggered.connect(self.show_process)
        self.action_ctlSettings.triggered.connect(
            self.show_controller_settings)
        self.action_svrSettings.triggered.connect(self.show_server_settings)

        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.customContextMenuRequested.connect(self._right_menu)
        XStream.stdout().messageWritten.connect(self.textEdit.insertPlainText)
        XStream.stderr().messageWritten.connect(self.textEdit.insertPlainText)
        logger.info('[*] Load system config')
        self.conf = Config('system.ini')
        self.system = None
        self.thread_pool = QThreadPool()
        self.process = QProcess(self)
        self.process.readyRead.connect(self.data_ready)
        # self.process.waitForStarted(1)
        self.process.started.connect(lambda: self.write_data('help'))
        self.process.error.connect(self.on_error)
        # self.textEdit.textChanged.connect(lambda: self.write_data(self.textEdit.document()))
        # self.textEdit.textChanged.connect(lambda: print(self.textEdit.toPlainText()))
        # self.process.finished.connect(lambda: self.runButton.setEnabled(True))

        self.process_manager = WorkerManager(max_threads=4)
Beispiel #2
0
import pandas as pd
from controller.config import Config
from controller.data_label_utils import get_all_sentiment_labels
from controller.database_service import DatabaseService
from controller.ml_utils import MLUtils

config = Config()
dbs = DatabaseService(config)

# get databases
collection_names = ['sickhillary', 'baghdadi_dead', 'death_hoax']

# declare test parameters
description = "Experiment 2"
n_iterations_per_classifier = 100
test_ratio = 0.2
target_label = "tweet_sentiment_label"
classifier_dict = MLUtils.get_classifiers_standard_suite()
features_tested_dict = {'feature_nlp_afinn_swn': MLUtils.gen_feature_afinn_swn,
                        'feature_nlp_pos': MLUtils.gen_feature_pos,
                        'feature_term_tfidf': MLUtils.gen_feature_term_tfidf}

ml_collections_result = {}

# iterate through collections
for collection_name in collection_names:
    print("Collection: " + collection_name)
    # get labelled tweets (unique)
    mongo_search_query = {"tweet_sentiment_label": {"$exists": True}}
    mongo_filter_query = {"text": 1, "tweet_type": 1, "tweet_sentiment_label": 1}
    mongo_filter_query.update({label: 1 for label in get_all_sentiment_labels()})
from controller.config import Config
from controller.tweet_links_service import TweetLinksService
from controller.database_service import DatabaseService
from controller.database_utils import get_tweet_collections_only

config = Config()
dbs = DatabaseService(config)

db = dbs.get_db()
collection_names = get_tweet_collections_only(db.collection_names())

dls = TweetLinksService(dbs, config)
dls.gen_all_collection_links()

pass
Beispiel #4
0
    print "    ||     ||     |___|     "
    print " ___||_____||____|_____|____"
    print ""
    print "############################"
    print ""


if __name__ == '__main__':
    # Moveit! initialise and init node
    moveit_commander.roscpp_initialize(sys.argv)
    rospy.init_node('cobra_towers_of_hanoi', anonymous=True)

    # welcome screen
    show_tower_of_hanoi()

    config = Config(MAX_GRIPPER, NUMBER_OF_DISKS, DISK_HEIGHT, TOWER_HEIGHT,
                    TOWER_POSITION, DIFFERENT_HEIGHT_OF_TOWERS, DEBUG)

    # configure and initialise objects
    controller = Controller(config, DEBUG)

    # initialise planning scene
    world = World(controller.tower_array, controller.disk_array, config, DEBUG)

    # remove old objects from scene
    world.clean_up()

    # add new objects
    world.create_planning_scene()

    # start the game
    controller.tower_of_hanoi(world)
Beispiel #5
0
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.action_system_quit.triggered.connect(self.on_exit)
        self.action_system_restart.triggered.connect(self.on_restart)
        self.action_system_start.triggered.connect(self.on_start)
        self.action_cmd.triggered.connect(self.show_cmd)
        self.action_file.triggered.connect(self.show_file)
        self.action_process.triggered.connect(self.show_process)
        self.action_ctlSettings.triggered.connect(
            self.show_controller_settings)
        self.action_svrSettings.triggered.connect(self.show_server_settings)

        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.customContextMenuRequested.connect(self._right_menu)
        XStream.stdout().messageWritten.connect(self.textEdit.insertPlainText)
        XStream.stderr().messageWritten.connect(self.textEdit.insertPlainText)
        logger.info('[*] Load system config')
        self.conf = Config('system.ini')
        self.system = None
        self.thread_pool = QThreadPool()
        self.process = QProcess(self)
        self.process.readyRead.connect(self.data_ready)
        # self.process.waitForStarted(1)
        self.process.started.connect(lambda: self.write_data('help'))
        self.process.error.connect(self.on_error)
        # self.textEdit.textChanged.connect(lambda: self.write_data(self.textEdit.document()))
        # self.textEdit.textChanged.connect(lambda: print(self.textEdit.toPlainText()))
        # self.process.finished.connect(lambda: self.runButton.setEnabled(True))

        self.process_manager = WorkerManager(max_threads=4)

    def _right_menu(self, point):
        menu = QMenu()
        menu.addAction(self.action_file)
        menu.addAction(self.action_cmd)
        menu.addAction(self.action_process)
        menu.exec_(self.table.viewport().mapToGlobal(point))

    def init_system(self):
        logger.info('[*] Init system')
        self.prog = os.path.join(os.path.dirname(__file__), 'connector',
                                 self.conf.get('controller', 'connector'))
        self.port = self.conf.get('controller', 'port')
        self.password = self.conf.get('controller', 'password')

    def on_error(self):
        print(str(self.process.readAllStandardError(), encoding='utf-8'))

    def write_data(self, data):
        if not data.endswith('\n'):
            data += '\n'
            self.process.write(bytes(data, encoding='utf-8'))
            # self.process.closeWriteChannel()
            # self.process.waitForFinished()

    def on_start(self):
        logger.info('[*] System start')
        self.init_system()
        # self.process.start('python', ['/home/uuu/covertutils/examples/tcp_reverse_handler.py', '4433', 'pass'])
        self.process.start('c:/python27/python.exe',
                           [self.prog, self.port, self.password])
        # self.process.write('help\n')
        # self.process.closeWriteChannel()
        # self.process.waitForFinished(100)
        # self.process.start('cmd')
        # self.process.write(b'help')

    def on_write(self, e):
        print(e)
        self.textEdit.toPlainText()
        self.process.write(b'help')

        # from subprocess import *
        # from subprocess import STARTUPINFO  # 对于python2.7需要单独引用STARTUPINFO
        # from server.connector import tcp_reverse_handler
        # import os
        # startupinfo = STARTUPINFO()
        # startupinfo.dwFlags |= STARTF_USESHOWWINDOW
        # startupinfo.wShowWindow = SW_HIDE
        # print(os.getcwd())
        # self.system = Popen(['cmd c:\\python27\\python.exe '+ os.getcwd() + '\\'+self.conf.get('controller', 'connector'),
        #                      self.conf.get('controller', 'port'), self.conf.get('controller', 'password')], stdin=PIPE,
        #                     stdout=PIPE, stderr=PIPE, shell=False, startupinfo=startupinfo)
        # w = Worker(Popen("cmd"))
        # w.signals.result.connect(get_result)
        # # self.system.wait()
        # out, err = self.system.communicate(b'whoami')
        # print(out.decode('gbk'))
        # print(err)
        # print('system start')
        # cmd = 'cmd /c c:/python27/python.exe ' + self.conf.get('controller', 'connector')
        # args = [self.conf.get('controller', 'port'), self.conf.get('controller', 'password')]
        # self.system = QProcess(self)
        # self.system.start('cmd /c dir', ['.'])
        # self.system.readyReadStandardOutput.connect(lambda: print(self.system.readAllStandardOutput()))
        # self.system.readyReadStandardError.connect(lambda: self.system.readAllStandardError())
        # print(self.system.communicate('help'))

    # def callProgram(self):
    # run the process
    # `start` takes the exec and a list of arguments
    # self.process.start('ping', ['127.0.0.1'])
    # self.process.start('python', ['/home/uuu/covertutils/examples/tcp_reverse_handler.py', '4433', 'pass'])

    def data_ready(self):
        cursor = self.textEdit.textCursor()
        cursor.movePosition(cursor.End)
        cursor.insertText(str(self.process.readAll(), encoding='gbk'))
        self.textEdit.ensureCursorVisible()

    def on_restart(self):
        pass

    def on_exit(self):
        btn = QMessageBox.question(self, "退出", "是否确定退出?",
                                   QMessageBox.Ok | QMessageBox.Cancel)
        if btn == QMessageBox.Ok:
            qApp.quit()

    def show_cmd(self):
        cmd = DialogCmd(self)
        cmd.show()

    def show_file(self):
        file = DialogFile(self)
        file.show()

    def show_process(self):
        process = DialogProcess(self)
        process.show()

    def show_controller_settings(self):
        ctl = DialogCtlSettings(self, self.conf)
        ctl.show()

    def show_server_settings(self):
        svr = DialogSvrSettings(self, self.conf)
        svr.show()
Beispiel #6
0
import pandas as pd
from controller.data_label_utils import get_all_sentiment_labels
from pyexcelerate import Workbook
from controller.config import Config
from controller.database_service import DatabaseService

config = Config()
dbs = DatabaseService(config)

excel_save_path = config.get_excel_exports_dir() + "\data.xlsx"
wb = Workbook()

collection_rumors = ['sickhillary', 'baghdadi_dead', 'death_hoax']
collection_news = ['mosul_battle', 'us_economic_policy', 'trump_cabinet']
collection_all = collection_rumors + collection_news

for collection_name in collection_all:
    # get unique tweet list
    unique_tweet_list = dbs.get_unique_tweet_ids_for_collection(
        collection_name, sorted_by_childs_length=True)

    mongo_search_query = {}
    mongo_filter_query = {
        "_id": 1,
        "text": 1,
        "tweet_type": 1,
        "tweet_sentiment_label": 1
    }
    mongo_filter_query.update(
        {label: 1
         for label in get_all_sentiment_labels()})
Beispiel #7
0
import csv
import re

import pandas as pd
from controller.config import Config
from controller.data_label_utils import get_all_sentiment_labels
from controller.database_service import DatabaseService
from controller.tweet_csv_label_service import TweetCSVLabelService

config = Config()
dbs = DatabaseService(config)

# combine all known rumor tweets
collection_rumors = ['sickhillary', 'baghdadi_dead', 'death_hoax']
df_rumors = pd.DataFrame()
for collection_name in collection_rumors:
    mongo_search_query = {"tweet_sentiment_label": "s"}
    mongo_filter_query = {
        "text": 1,
        "tweet_type": 1,
        "tweet_sentiment_label": 1
    }
    mongo_filter_query.update(
        {label: 1
         for label in get_all_sentiment_labels()})
    tweets = dbs.get_unique_tweets_for_collection(
        collection_name,
        filter_query=mongo_filter_query,
        search_query=mongo_search_query)
    df = pd.DataFrame(tweets)
    df_rumors = df_rumors.append(df)