コード例 #1
0
def lambda_handler(event, context):
    logger.info('got event{}'.format(event))
    uuid = event['campaign_uuid']
    type_name = event['type']
    type_id = type_name.replace(' ', '_')

    campaign = Campaign(uuid)

    for type_key in campaign.types:
        if campaign.types[type_key]['type'] == type_name:
            typee = campaign.types[type_key]

    query = build_query(
        polygon=campaign.corrected_coordinates(),
        typee=typee)
    
    save_query(
        path=build_query_path(uuid, type_id),
        query=query)

    
    post_request(query, type_id)

    clean_aoi(campaign, type_id)

    save_to_s3(
        path=build_path(uuid, type_id),
        type_id=type_id)

    invoke_process_feature_completeness(uuid, type_name)
    invoke_process_count_feature(uuid, type_name)
    invoke_process_mapper_engagement(uuid, type_name)
コード例 #2
0
ファイル: controller.py プロジェクト: jueberschlag/Schnapi
 def start(self):
     print("Lancement du Controlleur principal")
     #Create the campaign
     print("Création de la campagne de fuzzing")
     camp = Campaign(self.name, self, self.nb_request)
     #Start the campaign
     print("Lancement de la campagne de fuzzing")
     camp.startCampaign()
     #End of campaign: image
     print("Création image Latex et R")
     self.monitor.img.fin()
コード例 #3
0
ファイル: singlemaps.py プロジェクト: Pragmapragma/soundrts
def _get_campaigns():
    w = []
    for mp in get_all_packages_paths():
        d = os.path.join(mp, "single")
        if os.path.isdir(d):
            for n in os.listdir(d):
                p = os.path.join(d, n)
                if os.path.isdir(p):
                    if n == "campaign":
                        w.append(Campaign(p, [4267]))
                    else:
                        w.append(Campaign(p))
    return w
コード例 #4
0
ファイル: game.py プロジェクト: thgcode/soundrts
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     res.set_mods(mods)
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert([1029, 4012]) # hostile sound  "version error"
         warning("Version mismatch. Version should be: %s. Mods should be: %s.",
                 version, mods)
     campaign_path_or_packed_map = self.replay_read()
     if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
         from campaign import Campaign
         self.map = Campaign(campaign_path_or_packed_map)._get(int(self.replay_read()))
     else:
         self.map = Map()
         self.map.unpack(campaign_path_or_packed_map)
     players = self.replay_read().split()
     self.alliances = map(int, self.replay_read().split())
     self.factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x in ["aggressive", "easy"]: # the "ai_" prefix wasn't recorded
             self.players += [DummyClient(x)]
         else:
             self.players += [HalfDummyClient(x)]
             self.me.nb_humans += 1
コード例 #5
0
ファイル: simulate.py プロジェクト: JulyKe/FODP-Sim
 def __init__(self, mission_time, plus_one, num_servers,
              num_disks_per_server, num_spares_per_server, k, m, fb,
              dp_type, failure_type, mtbf, failure_percent, rebuildIO,
              slaTime, copybackIO, diskCap, useRatio):
     #---------------------------
     # compressed time window
     #---------------------------
     self.mission_time = mission_time
     #---------------------------
     # system and placement
     #---------------------------
     self.sys = Campaign(plus_one, num_servers, num_disks_per_server,
                         num_spares_per_server, k, m, fb, dp_type, diskCap,
                         useRatio)
     self.place = Placement(self.sys)
     #--------------------------------------
     # fast rebuild + copyback phases
     #--------------------------------------
     self.rebuild = Rebuild(self.sys, rebuildIO)
     self.copyback = Copyback(copybackIO, slaTime)
     #--------------------------------------
     # failures distribution and mtbf
     #--------------------------------------
     self.mtbf = mtbf
     self.failure_type = failure_type
     self.failure_percent = failure_percent
コード例 #6
0
def main(event, context):
    uuid = event['campaign_uuid']
    campaign = Campaign(uuid)

    for type_key in campaign.types:
        payload = json.dumps({
            'campaign_uuid': uuid,
            'type': campaign.types[type_key]['type']
        })
        invoke_download_overpass_data(payload)
コード例 #7
0
def lambda_handler(event, context):
    aws_lambda = boto3.client('lambda')
    merge_func_name = '{0}_process_merge_mbtiles'.format(os.environ['ENV'])

    for campaign in Campaign.active():
        compute_campaign(campaign)
        if needs_merge(campaign) is True:
            aws_lambda.invoke(FunctionName=merge_func_name,
                              InvocationType='Event',
                              Payload=json.dumps({'uuid': campaign}))
コード例 #8
0
ファイル: game.py プロジェクト: sabren/blaze
 def EVT_tick(self,event):
     if self.delay:
         self.delay -= 1
     else:
         filename = Campaign.next(self.level.replace('\\','/'))
         if filename:
             lvl = level.load(filename)
             level.save(lvl,'save.lvl')
             self.quit(GameState(lvl))
         else:
             self.quit(Ending())
コード例 #9
0
def master_main(campaign_dir):
    ip = requests.get('https://api6.ipify.org').text
    print('Address: {}'.format(ip))

    resource_provider = LocalResourceProvider(campaign_dir)
    campaign = Campaign(resource_provider)
    state = State(campaign, player=None)
    res_server = resserver.ResourceServer(campaign_dir, campaign)
    api_server = apiserver.ApiServer()

    manager = Manager(state, api_server)

    pyglet.app.run()

    campaign.save()

    api_server.shutdown()
    res_server.shutdown()
    api_server.join()
    res_server.join()
コード例 #10
0
 def __sort_campaigns(self):
     api = Api()  # Initialize the API
     campaigns_response = api.request(
         "/api/campaigns/")  #Request the camapaigns to the API
     for campaign_response in campaigns_response:
         if self.prefix in campaign_response[
                 'name']:  # Check ih the campaign match the customer
             campaign = Campaign(
                 campaign_response
             )  #Create campaign an append to the list of campaigns
             self.campaigns.append(campaign)
def read_election_data(working_directory, filename):
    from campaign import Campaign
    list_of_campaigns = []
    election_info = generate_line_data(working_directory, filename)
    for line in election_info:
        dictionary_of_line_data = line[0]
        line_number = line[1]
        number_of_lines = line[2]
        if line_number % 200 == 0:
            print("Reading line " + str(line_number) + " out of " + str(number_of_lines) + ".")
        campaign = Campaign(dictionary_of_line_data)
        list_of_campaigns.append(campaign)
    return list_of_campaigns
コード例 #12
0
def lambda_handler(event, context):
    uuid = event['campaign_uuid']
    print(uuid)
    campaign = Campaign(uuid)
    # features = get_unique_features(
    #     functions=campaign._content_json['selected_functions'])

    for type_key in campaign.types:
        payload = json.dumps({
            'campaign_uuid': uuid,
            'type': campaign.types[type_key]['type']
        })
        invoke_download_overpass_data(payload)
コード例 #13
0
    def createCampaign(self, title, sender, recipients, subj, body):
        newCampaign = Campaign(title,
                               sender,
                               recipients,
                               message_subj=subj,
                               message_body=body)

        while newCampaign.getID() in self.campaigns:
            newCampaign = Campaign(title,
                                   sender,
                                   recipients,
                                   message_subj=subj,
                                   message_body=body)

        self.campaigns.append({'id': newCampaign.getID(), 'title': title})
        newCampaign.save()
        return newCampaign
コード例 #14
0
ファイル: game.py プロジェクト: sabren/blaze
 def __init__(self,lvl=None):
     State.__init__(self)
     if lvl == None:
         self.level = level.load(Campaign.next())
     else:
         self.level = lvl
     self.bg = pygame.sprite.Group(self.level.s)
     self.selected = None
     self.audio = Audio()
     self.music = Music()
     self.music.volume = 1
     self.audio.volume = 0.5
     self.alarm = 0
     self.music.stop(500)
     self.music.play('data/music/play.ogg',-1)
     self.playing = True
コード例 #15
0
def player_main(address, player, port):
    address = ipaddress.ip_address(address)
    assert address.version == 6
    master_address = address.exploded

    api_server = apiserver.ApiServer(master_address, port=port)
    request = {'id': 1, 'method': 'hi', 'params': {'player': player}}
    api_server.send(request)

    resource_provider = RemoteResourceProvider(master_address)
    campaign = Campaign(resource_provider)
    state = State(campaign, player)
    manager = Manager(state, api_server)

    pyglet.app.run()

    api_server.shutdown()
    api_server.join()
コード例 #16
0
 def __init__(self, replay):
     self._file = open(replay)
     game_type_name = self.replay_read()
     if game_type_name in ("multiplayer", "training"):
         self.default_triggers = _MultiplayerGame.default_triggers
         self.must_apply_equivalent_type = True
     game_name = self.replay_read()
     voice.alert([game_name])
     version = self.replay_read()
     mods = self.replay_read()
     res.set_mods(mods)
     _compatibility_version = self.replay_read()
     if _compatibility_version != compatibility_version():
         voice.alert(mp.BEEP + mp.VERSION_ERROR)
         warning(
             "Version mismatch. Version should be: %s. Mods should be: %s.",
             version, mods)
     campaign_path_or_packed_map = self.replay_read()
     if game_type_name == "mission" and "***" not in campaign_path_or_packed_map:
         from campaign import Campaign
         self.map = Campaign(campaign_path_or_packed_map)._get(
             int(self.replay_read()))
     else:
         self.map = Map()
         self.map.unpack(campaign_path_or_packed_map)
     players = self.replay_read().split()
     alliances = self.replay_read().split()
     factions = self.replay_read().split()
     self.seed = int(self.replay_read())
     self.me = ReplayClient(players[0], self)
     self.players = [self.me]
     for x in players[1:]:
         if x.startswith("ai_"):
             x = x[3:]
         if x in ["aggressive", "easy", "ai2"]:
             self.players += [DummyClient(x)]
         else:
             self.players += [RemoteClient(x)]
             self.me.nb_humans += 1
     for p, a, f in zip(self.players, alliances, factions):
         p.alliance = a
         p.faction = f
コード例 #17
0
 def insert(self, conn, cur):
     c = Campaign(conn, cur)
     self.c_id = c.cid
     e = Event(conn, cur)
     self.e_id = e.eid
     w = Weblink(conn, cur)
     self.w_id = w.wid
     s = Supporter(conn, cur)
     self.s_id = s.sid
     self.g_id = s.gid
     cur.execute(
         """
     INSERT INTO Operations_S_Members(c_id, e_id, w_id, s_id, g_id, date_time)
     VALUES ((SELECT cid FROM  Campaigns WHERE  tupleNo=%(c_id)s), (SELECT eid FROM  Events WHERE  tupleNo=%(e_id)s), (SELECT wid FROM  Weblinks WHERE  tupleNo=%(w_id)s), (SELECT sid FROM Supporters WHERE tupleNo=%(s_id)s), (SELECT gid FROM S_MEMBERS WHERE s_id = (SELECT sid FROM Supporters WHERE tupleNo=%(s_id)s)), %(date_time)s);
     """, {
             "c_id": self.c_id,
             "e_id": self.e_id,
             "w_id": self.w_id,
             "s_id": self.s_id,
             "g_id": self.g_id,
             "date_time": self.date_time
         })
     conn.commit()
コード例 #18
0
ファイル: banner.py プロジェクト: hint/django-openx
    def campaign(self):
        from campaign import Campaign

        return Campaign.get(self["campaignId"])
コード例 #19
0
import unittest
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
from campaign import Campaign

campaign = Campaign()
mock_submissions_json = {'total': '2',
                         'submissions': [
                            {'remote_addr': '50.115.104.50',
                              'read': '1',
                              'timestamp': '2015-10-09 17:17:31',
                              'longitude': '-80.193702697754',
                              'user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
                              'payment_status': '',
                              'latitude': '25.774299621582',
                              'id': '218459301'},
                            ],
                         'pages': 1
                        }
mock_submission_ids = ['218459301']
mock_submission = [{'field': '36379032', 'value': 'Fermin'}, {'field': '36491672', 'value': 'Carranza'}, {'field': '36491671', 'value': 'Liberal'}]
mock_voter_data = {'first_name': 'Fermin', 'last_name': 'Carranza', 'views': 'Liberal'}

class CampaignTests(unittest.TestCase):
    def test_generate_politician_instances_should_return_two_politicians(self):
        self.failUnless(len(campaign.politicians) == 2)

    def test_generate_voter_instances_should_return_0_or_greater(self):
        self.failIf(len(campaign.voters) < 0)
コード例 #20
0
ファイル: advertiser.py プロジェクト: hint/django-openx
    def campaigns(self):
        from campaign import Campaign

        return Campaign.get_for_advertiser(self)
コード例 #21
0
import ZODB, ZODB.FileStorage, transaction, persistent
from campaign import Campaign

storage = ZODB.FileStorage.FileStorage('mycampaign.fs')
db = ZODB.DB(storage)
connection = db.open()
campaign_root = connection.root

campaign_root.campaign = Campaign()
campaign_root.campaign.newParty()
campaign_root.campaign.addPlayer("Jeremie")
transaction.commit()
コード例 #22
0
    print("Fetched {} campaigns".format(len(data)))


def pretty_print_status(cp, status):

    print("Campaign Name: ", cp["name"])
    print("Active: ", cp["started"])
    print("Status: ", status["sent"], "/", status["total"],
          "(Completed)" if status["total"] == status["sent"] else "")


if __name__ == "__main__":
    arguments = parse_arguments()
    command = arguments.command

    campaign = Campaign(db, campaignCollection)
    chakraInstance = Chakra(auth)
    pp = not (arguments.format and arguments.format == "json")

    # print banner
    if pp:
        print("    Twitter Campaigns CLI v0.1")
        print("    ==========================")
        print()

    if command == "add":
        # add command
        pp and print("[+] Authenticating.....", end='')
        me = chakraInstance.get_me()
        user_id = me["id"]
        print("Authenticated as", me["name"])
コード例 #23
0
def lambda_handler(event, context):
    for campaign in Campaign.active():
        compute_campaign(campaign)
コード例 #24
0
def main():
    try:
        arguments = get_arguments()
        campaign_name = arguments.name
        variants = arguments.variants
        debug = arguments.debug
        conditions = arguments.conditions
        campaign = Campaign(campaign_name, debug=True, variants=variants)

        campaign.setup_folder()
        campaign.inject_files()
        campaign.populate_file()

        condition_mapping = campaign.get_condition_mapping()
        if conditions:
            for condition in conditions:
                if condition not in condition_mapping:
                    raise ValueError("Invalid Condition {}".format(condition))
            campaign.inject_eligibility_criteria(conditions)
    except Exception as e:
        print(e)
コード例 #25
0
except ImportError:
    from urlparse import urlparse
import os
from flask_cors import CORS

ConsumerKey = os.getenv("ConsumerKey")
ConsumerSecret = os.getenv("ConsumerSecret")
TWITTER_REQUEST_TOKEN_URL = "https://api.twitter.com/oauth/request_token"
TWITTER_ACCESS_TOKEN_URL = "https://api.twitter.com/oauth/access_token"

app = Flask(__name__)
cors = CORS(app)

request_token = {}

campaign = Campaign(db, campaignCollection)
user = User(db, userCollection)


class AuthConfig():
    def __init__(self):
        self.ChakraInstance = ''

    def set_chakra(self, auth):
        self.ChakraInstance = Chakra(auth)

    def get_chakra(self):
        return self.ChakraInstance

    def del_chakra(self):
        del self.ChakraInstance
コード例 #26
0
 def start_map(self):
     nr = self.selected + (self.cur_page * self.max_lines)
     if nr < len(self.map_list):
         self.next = Campaign(nr)
         self.quit()
コード例 #27
0
import telegram
import logging
import matcher

##############################################################################################################################################################################
# Start command
##############################################################################################################################################################################

# This is the Start command (/start).
# In the Start Command, the bot will ask the user about his basic information which include:
# firstname, lastname, birthdate, phonenumber, address, location
# these info will be stored in a Class User and then they will be stored in the database

# Class User
u1 = User()
c1 = Campaign()
offer = Offer()
request = []

# These are the states  of the Start command
CHOOSING, PHONE_NUMBER, PHONE_NUMBER_YN, BIRTHDATE, BIRTHDATE_YN, ADDRESS, ADDRESS_YN, LOCATION, CONCLUDE , MENU, WELCOME, ACTIONS, \
OFFER_TYPE, OFFER_DESCRIPTION, OFFER_QUANTITY, OFFER_done, REQUEST_TYPE, REQUEST_DESCRIPTION, REQUEST_QUANTITY, REQCASH_ESTIMATE, \
REQUEST_NOTED, NEW_VOLUNTEER, CHOOSE_VALUES_TO_UPDATE, U_ADDRESS, U_LOCATION, START_DELIVERY, DELIVERY_SUCCESS, DELIVERY_FAILURE, CHOOSE_DONATION, \
CHOOSE_OFFER, SAVE_OFFER, ASK_OFFER_ID, DELIVER_NEEDS, UPDATE_NEED, ASK_NEED_ID,NEW_DONATION_TYPE, ESTIMATING_NEW_DONATION_VALUE, NEW_REQUEST_TYPE, \
ESTIMATING_NEW_NEED_VALUE, GO_MENU, CHOOSE_CONFIRM, RECEIVED_NEED, NOT_RECEIVED_NEED, START_CAMP, CAMP_NAME, CAMP_D, CAMP_L, CONCLUDE_CAMP = \
    range(48)


def actions(update: Update, context: CallbackContext) -> int:
    reply_keyboard = [['Donate'], ['Volunteer'], ['Request'], ['Nothing'],
                      ['Show Offers'], ['Updates on pickups'], ['Show Needs'],
コード例 #28
0
 def do_quit(self):
     self.next = Campaign()
     self.quit()