Exemple #1
0
 def writeStopFile(self, sentimentId):
     import sys
     sys.path.append('/Users/melihozkan/Desktop/Projects/BitirmeProjesi/')
     from utils.hdfsClient import client
     tmp = client()
     tmp.overwrite(path="/tweepy/" + str(sentimentId) + "_stop.txt",
                   data="test")
Exemple #2
0
 def handler(signal_received, frame):
     if (sm != None):
         import sys
         sys.path.append(
             '/Users/melihozkan/Desktop/Projects/BitirmeProjesi/')
         from utils.hdfsClient import client
         tmp = client()
         tmp.overwrite(path="/tweepy/" + sentimentId + "_stop.txt",
                       data="stop")
         sm.stopStreaming()
 def get_text_result(self):
     total, processed, positive, negative = self.__get__results()
     c = client()
     result = "Total: {} \n Processed = {} \n Positive = {} - {} % \n Negative: {} - {} %".format(
         total, processed, positive,
         round(float(positive * 100 / processed), 1), negative,
         round(float(negative * 100 / processed), 1))
     path = self.get_report_path()
     c.overwrite(path, result)
     self.reportFilePath = path
     self.save()
 def readhdfs(self):
     c = client()
     if self.reporttype == "text":
         read = c.read(self.reportFilePath)
         return read.replace('\n', '<br>')
     elif self.reporttype == "pie":
         staticName = "/static/reports/report_{}.png".format(self.reportid)
         path = "/Users/melihozkan/Desktop/Projects/BitirmeProjesi/web/webApp" + staticName
         content = "<img style=\"width:500px; height=500px\" src=\"{}\" alt=\"Pie Report\">".format(
             path)
         return content
Exemple #5
0
def detail(request, reportid):
    rpt: report = get_object_or_404(report, reportid=reportid)
    c = client()
    if rpt.reporttype == "text":
        content = c.read(rpt.reportFilePath)
    elif rpt.reporttype == "pie":
        image = c.readByte(rpt.get_report_path())
        staticName = "/static/reports/report_{}.png".format(rpt.reportid)
        path = "/Users/melihozkan/Desktop/Projects/BitirmeProjesi/web/webApp" + staticName
        with open(path, "wb") as writer:
            writer.write(image)
        content = staticName

    context = {'report': rpt, 'content': content}
    return render(request, "reportService/detail.html", context)
 def sendTweets(self, tweets):
     from utils.hdfsClient import client
     cl = client()
     count = 0
     for i in tweets:
         id = i["tweetid"]
         text = i["tweet_text"]
         msg2 = id + text
         if cl.read("/tweepy/" + self.sentimentId + "_stop.txt") == "stop":
             print("Stop Signal")
             break
             self.c_socket.send(
                 "<tweet>{}</tweet>\n".format(msg2).encode("utf-8"))
             print(count)
             count = count + 1
def sentiment_log(request, sentimentId):
    id = uuid.UUID(sentimentId)
    snt: sentiments = get_object_or_404(sentiments, sentimentid=id)
    path = snt.get_log_path()
    if snt.startdate == None:
        msg.error(request, "No Log. Sentiment not running.")
        return HttpResponseRedirect(snt.get_absolute_url())
    import sys
    sys.path.append('/Users/melihozkan/Desktop/Projects/BitirmeProjesi/')
    from utils.hdfsClient import client
    cl = client()
    log = cl.read(path)
    context = {'sentimentLog': log, 'sentimentId': sentimentId}

    return render(request, "sentimentManage/log.html", context)
 def get_pie_chart(self):
     total, processed, positive, negative = self.__get__results()
     unprocessed = total - processed
     c = client()
     labels = ["Unprocessed", "Positive", "Negative"]
     sizes = [unprocessed, positive, negative]
     explode = (0, 0.1, 0.1)
     fig1, ax1 = plt.subplots()
     ax1.pie(sizes,
             explode=explode,
             labels=labels,
             autopct='%1.1f%%',
             shadow=True,
             startangle=90)
     ax1.axis('equal'
              )  # Equal aspect ratio ensures that pie is drawn as a circle.
     path = self.get_report_path()
     c.writeMathplot(path, plt)
     self.reportFilePath = path
     self.save()
 def __init__(self, c_socket):
     self.c_socket: socket.socket = c_socket
     self.sqlFunctions = SqlFunctions()
     self.jsonF = JsonFormatter()
     self.cl = client()
Exemple #10
0
def test():
    from utils.hdfsClient import client
    a = client()
    print(a.read("/logs/sentimentlog_1480.log"))
Exemple #11
0
 def __init__(self):
     self.__hdfs = client()