Exemple #1
0
def get_mood_dictionary(date_dictionary):
    mood_dictionary = dict()

    for date in date_dictionary:
        english_time = TimeService().get_string_from_timestamp(date)
        print('------' + english_time)
        print(TextBlob(date_dictionary[date]))
        print(TextBlob(date_dictionary[date]).sentiment.polarity)
        print('-----------')
        mood_dictionary[date] = TextBlob(
            date_dictionary[date]).sentiment.polarity

    return mood_dictionary
Exemple #2
0
def get_date_dictionary(tweets):
    date_dictionary = dict()

    for tweet in tweets:
        tweet_date = tweet["created_at"]
        tweet_timestamp = TimeService().get_timestamp(tweet_date)
        tweet_content = remove_twitter_url(tweet["text"])

        if tweet_date in date_dictionary.keys():
            date_dictionary[tweet_timestamp] += ' ' + tweet_content
        else:
            date_dictionary[tweet_timestamp] = tweet_content

    print(date_dictionary)
    return date_dictionary
Exemple #3
0
def main():
    # Make socket
    transport = TSocket.TSocket('localhost', 9090)

    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TBufferedTransport(transport)

    # Wrap in a protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a client to use the protocol encoder
    client = TimeService.Client(protocol)

    # Connect!
    transport.open()

    ts = client.get_time()
    print('Client Received {}'.format(ts))

    # Close!
    transport.close()
Exemple #4
0
    def plot_graph(self, data_dict, username):
        graph_df = self.get_graph_dataframe(data_dict)
        print(graph_df)
        y_values = graph_df['sentiment'].values
        x_values = []
        for index in graph_df.index:
            x_values.append(TimeService().get_string_from_timestamp(index))

        print(x_values)
        print(y_values)

        plt.plot(x_values, y_values, 'c')

        plt.title(f'Sentiment of @{username} based on recent tweets')
        plt.xlabel('Days')
        plt.ylabel('Sentiment')
        # plt.legend()

        plt.grid(True, color='k')

        plt.show()
Exemple #5
0
import sys
import time

from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
from thrift.transport import TSocket, TTransport
sys.path.append('gen-py')
from time_service import TimeService


class TimeHandler:
    def __init__(self):
        self.log = {}

    def get_time(self):
        return time.ctime()


if __name__ == '__main__':
    handler = TimeHandler()
    processor = TimeService.Processor(handler)
    transport = TSocket.TServerSocket(host='127.0.0.1', port=9090)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

    print('Starting the server...')
    server.serve()
    print('done.')
def start_services(save_slot_data):
    global service_manager
    if service_manager is None:
        service_manager = GameServiceManager()
        from apartments.landlord_service import LandlordService
        from business.business_service import BusinessService
        from call_to_action.call_to_action_service import CallToActionService
        from clock import GameClock
        from clubs.club_service import ClubService
        from event_testing.event_manager_service import EventManagerService
        from server.clientmanager import ClientManager
        from server.config_service import ConfigService
        from services.cheat_service import CheatService
        from services.roommate_service import RoommateService
        from services.style_service import StyleService
        from sims.household_utilities.utilities_manager import UtilitiesManager
        from sims.household_manager import HouseholdManager
        from sims.aging.aging_service import AgingService
        from services.relgraph_service import RelgraphService
        from sims.sim_info_manager import SimInfoManager
        from time_service import TimeService
        from tutorials.tutorial_service import TutorialService
        from curfew.curfew_service import CurfewService
        from sickness.sickness_service import SicknessService
        from trends.trend_service import TrendService
        from relationships.relationship_service import RelationshipService
        from sims.hidden_sim_service import HiddenSimService
        from holidays.holiday_service import HolidayService
        from seasons.season_service import SeasonService
        from weather.weather_service import WeatherService
        from services.rabbit_hole_service import RabbitHoleService
        from lot_decoration.lot_decoration_service import LotDecorationService
        from narrative.narrative_service import NarrativeService
        from organizations.organization_service import OrganizationService
        from services.object_lost_and_found_service import ObjectLostAndFoundService
        from civic_policies.street_civic_policy_service import StreetService
        from venues.venue_service import VenueGameService
        from global_policies.global_policy_service import GlobalPolicyService
        service_list = [
            BusinessService(),
            CallToActionService(),
            GameClock(),
            TimeService(),
            ConfigService(),
            CheatService(),
            EventManagerService(),
            ClientManager(manager_id=MGR_CLIENT),
            UtilitiesManager(),
            HouseholdManager(manager_id=MGR_HOUSEHOLD),
            RelationshipService(),
            RelgraphService.get_relgraph_service(),
            AgingService(),
            SimInfoManager(manager_id=MGR_SIM_INFO),
            CurfewService(),
            SicknessService(),
            HiddenSimService(),
            HolidayService(),
            SeasonService(),
            WeatherService(),
            NarrativeService(),
            GlobalPolicyService(),
            ClubService(),
            RabbitHoleService(),
            LotDecorationService(),
            StyleService(),
            TutorialService(),
            TrendService(),
            ObjectLostAndFoundService(),
            LandlordService(),
            RoommateService(),
            OrganizationService(),
            StreetService(),
            VenueGameService()
        ]
        for service in service_list:
            if service is not None:
                service_manager.register_service(service)
        service_manager.start_services(container=service_manager,
                                       save_slot_data=save_slot_data)
Exemple #7
0
 def start_services(self, gameplay_zone_data, save_slot_data):
     _distributor = distributor.system.Distributor.instance()
     self.sim_quadtree = placement.get_sim_quadtree_for_zone(self.id)
     self.single_part_condition_list = weakref.WeakKeyDictionary()
     self.multi_part_condition_list = weakref.WeakKeyDictionary()
     from objects.object_manager import ObjectManager, PropManager, PartyManager, InventoryManager, SocialGroupManager
     from sims.sim_info_manager import SimInfoManager
     from server.clientmanager import ClientManager
     from sims.household_manager import HouseholdManager
     from autonomy.autonomy_service import AutonomyService
     from ui.ui_dialog_service import UiDialogService
     from server.config_service import ConfigService
     from event_testing.test_events import EventManager
     from situations.situation_manager import SituationManager
     from filters.sim_filter_service import SimFilterService
     from socials.clustering import ObjectClusterService, SocialGroupClusterService
     from postures.posture_graph import PostureGraphService
     from animation.arb_accumulator import ArbAccumulatorService
     from world.travel_service import TravelService
     from situations.service_npcs.service_npc_manager import ServiceNpcService
     from story_progression.story_progression_service import StoryProgressionService
     from sims.master_controller import MasterController
     from filters.neighborhood_population_service import NeighborhoodPopulationService
     from services.lot_spawner_service import LotSpawnerService
     from zone_spin_up_service import ZoneSpinUpService
     from interactions.privacy import PrivacyService
     from services.age_service import AgeService
     from situations.ambient.ambient_service import AmbientService
     from broadcasters.broadcaster_service import BroadcasterService
     from services.super_speed_three_service import SuperSpeedThreeService
     from services.fire_service import FireService
     from services.cleanup_service import CleanupService
     from time_service import TimeService
     from sims4.sim_irq_service import SimIrqService
     from venues.venue_service import VenueService
     from services.reset_and_delete_service import ResetAndDeleteService
     services = [
         GameClock(), TimeService(), ConfigService(), SimIrqService(),
         EventManager(), ClientManager(manager_id=MGR_CLIENT),
         HouseholdManager(manager_id=MGR_HOUSEHOLD),
         ResetAndDeleteService(), ObjectManager(manager_id=MGR_OBJECT),
         InventoryManager(manager_id=MGR_OBJECT), AgeService(),
         SimInfoManager(manager_id=MGR_SIM_INFO),
         PropManager(manager_id=MGR_OBJECT), PostureGraphService(),
         ArbAccumulatorService(None, None), AutonomyService(),
         SituationManager(manager_id=MGR_SITUATION), SimFilterService(),
         PartyManager(manager_id=MGR_PARTY),
         SocialGroupManager(manager_id=MGR_SOCIAL_GROUP), UiDialogService(),
         ObjectClusterService(), SocialGroupClusterService(),
         TravelService(), NeighborhoodPopulationService(),
         ServiceNpcService(), LotSpawnerService(), VenueService(),
         AmbientService(), StoryProgressionService(), ZoneSpinUpService(),
         PrivacyService(), FireService(), BroadcasterService(),
         CleanupService(), SuperSpeedThreeService(), CareerService(),
         MasterController()
     ]
     from sims4.service_manager import ServiceManager
     self.service_manager = ServiceManager()
     for service in services:
         self.service_manager.register_service(service)
     self.client_object_managers = set()
     self.service_manager.start_services(
         zone=self,
         gameplay_zone_data=gameplay_zone_data,
         save_slot_data=save_slot_data)
     self.navmesh_alarm_handle = alarms.add_alarm_real_time(
         self,
         clock.interval_in_real_seconds(1),
         self._check_navmesh_updated_alarm_callback,
         repeating=True,
         use_sleep_time=False)
     self._royalty_alarm_manager.start_schedule()