def procinst_delete(procInstId):
    my_url = getKey('url')
    my_url = my_url + '/engine/default/process-instance/' + procInstId

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.delete(my_url, auth=HTTPBasicAuth(my_user, my_pass))
    if resp.status_code != 204:
        raise Exception(resp.status_code, resp.text)
def procdef_get(procDefId):
    my_url = getKey('url')
    my_url = my_url + '/engine/default/process-definition/' + procDefId

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.get(my_url, auth=HTTPBasicAuth(my_user, my_pass))
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
示例#3
0
def hcleanup_getconfig():
    my_url = getKey('url')
    my_url = my_url + '/engine/default/history/cleanup/configuration'

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.get(my_url, auth=HTTPBasicAuth(my_user, my_pass))
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
def procdef_set_hittl(procDefId, hittl):
    my_url = getKey('url')
    my_url = my_url + '/engine/default/process-definition/' + procDefId + '/history-time-to-live'

    my_user = getKey('username')
    my_pass = getKey('password')

    my_data = '{"historyTimeToLive":' + str(hittl) + '}'

    headers = {'Content-Type': 'application/json'}
    resp = requests.put(my_url,
                        auth=HTTPBasicAuth(my_user, my_pass),
                        data=my_data,
                        headers=headers)
    if resp.status_code != 204:
        raise Exception(resp.status_code, resp.text)
示例#5
0
def hcleanup_schedulejob(now):
    params = {}
    if now == False:
        params['executeAtOnce'] = 'false'

    my_url = getKey('url')
    my_url = my_url + '/engine/default/history/cleanup'

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.post(my_url,
                         auth=HTTPBasicAuth(my_user, my_pass),
                         params=params)
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
示例#6
0
def deployment_list(tenantId):
    params = {}
    if tenantId != None:
        params['tenantIdIn'] = tenantId

    my_url = getKey('url')
    my_url = my_url + '/engine/default/deployment'

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.get(my_url,
                        params=params,
                        auth=HTTPBasicAuth(my_user, my_pass))
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
def procdef_count(tenantId):
    if tenantId != None:
        params = {'tenantIdIn': tenantId}
    else:
        params = {}

    my_url = getKey('url')
    my_url = my_url + '/engine/default/process-definition/count'

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.get(my_url,
                        params=params,
                        auth=HTTPBasicAuth(my_user, my_pass))
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
示例#8
0
文件: views.py 项目: kevando/chewy
	def get(self,urlKey):

		templateValues = {
                'placeholder':'Enter Human Language',
                'key':config.getKey(),
                'BASE_URL':config.getRootURL(),
                'totalTranslations': getTotalTranslations(self),
        }
		path = os.path.join(os.path.dirname(__file__), 'main.html')
		self.response.out.write(template.render(path, templateValues))
示例#9
0
def deployment_delete(deploymentId, doCascade, skipListeners, skipIoMappings):
    params = {}
    if doCascade == True:
        params['cascade'] = 'true'
    if skipListeners == True:
        params['skipCustomListeners'] = 'true'
    if skipIoMappings == True:
        params['skipIoMappings'] = 'true'

    my_url = getKey('url')
    my_url = my_url + '/engine/default/deployment/' + deploymentId

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.delete(my_url,
                           auth=HTTPBasicAuth(my_user, my_pass),
                           params=params)
    if resp.status_code != 204:
        raise Exception(resp.status_code, resp.text)
def procinst_for_procdefid(procDefId, deploymentid):
    params = {}
    if procDefId != None:
        params['processDefinitionId'] = procDefId
    if deploymentid != None:
        params['deploymentId'] = deploymentid

    my_url = getKey('url')
    my_url = my_url + '/engine/default/process-instance'

    my_user = getKey('username')
    my_pass = getKey('password')

    resp = requests.get(my_url,
                        auth=HTTPBasicAuth(my_user, my_pass),
                        params=params)
    if resp.status_code != 200:
        raise Exception(resp.status_code, resp.text)
    respjson = json.loads(resp.text)
    return respjson
示例#11
0
 def _login(self):
   '''
   Performs a login by posting the username, password and collecting the cookie.
   
   returns nothing
   '''
   params = urllib.parse.urlencode({
       'username' : self.username,
       'password' : self.password,
       'login' : 'Login'
     }).encode(self.encoding)
   
   response = self.opener.open(config.getKey('login_url'), params)
   return
示例#12
0
 def rangeBan(self,ip,reason,botid='',unban=False):
   self._checkLogin()
   
   page = config.getKey('rangeban_url')
   
   params = {
     'ip':ip,
     'reason':reason,
     'targetbot':botid
   }
   
   if unban:
     params['unban'] = 'unban'
   
   self._csnfPost(page,params)
示例#13
0
文件: views.py 项目: kevando/chewy
	def post(self,urlKey):
		# uuserInput = self.request.get_all('translations_public')
		# dude(uuserInput)
		userInput = self.request.get('phrase')
		newUrlKey = translateToWookie(userInput,self.request.remote_addr,self)
		translation = Translation.get_by_id(newUrlKey)

		templateValues = {
            'totalTranslations': getTotalTranslations(self),
            'placeholder':translation.english,
            'translation':translation.wookie,
            'translationId':translation.key().id(),
            'key':config.getKey(),
            'BASE_URL':config.getRootURL(),
            'translationsPublic':self.session.get('translations_public'),
            'translationsPublicCheck' : self.session.get('translations_public') == True and 'checked' or 'unchecked',
            'translations_public' : self.request.get('translations_public') # not currently getting this data
        }

		pushTranslationToZapier(templateValues)
		path = os.path.join(os.path.dirname(__file__), 'translated.html')
		self.response.out.write(template.render(path, templateValues))
def generateMainWindow(frame):
    frame.wm_title("User Console")
    global USERNAME
    global PASSWORD

    #Open file browser dialog
    def browseFile(fileVar, fileLocationVar):
        from tkinter import filedialog
        fileLocation = filedialog.askopenfilename(filetypes=[("Any", "*.*")])
        if len(fileLocation) > 0:
            displayName = str(fileLocation).split('/')
            fileVar.set(displayName[-1])
            fileLocationVar.set(fileLocation)
        return

    #Download File row
    downloadOption = StringVar()
    downloadOption.set("Select File")
    serverFiles = getFileNames()
    downloadFileLabel = Label(text="Download File")
    downloadFileLabel.grid(row=0, column=0, sticky="W")
    dropDown = OptionMenu(frame, downloadOption, *serverFiles)
    dropDown.grid(row=0, column=1, padx=5, pady=5)
    downloadButton = Button(text="Download File", command = lambda: downloadFile(downloadOption.get()))
    downloadButton.grid(row=0, column=2, padx=5, pady=5)

    #Upload File row
    uploadOption = StringVar()
    uploadOption.set("Browse...")
    uploadFileLocation = StringVar()
    uploadFileLocation.set("Browse...")

    uploadFileLabel = Label(text="Upload File")
    uploadFileLabel.grid(row=1, column=0, sticky="W")
    uploadBrowseButton = Button(textvar=uploadOption, command=lambda: (browseFile(uploadOption, uploadFileLocation)))
    uploadBrowseButton.grid(row=1, column=1, padx=5, pady=5)

    uploadButton = Button(text="Upload File", command=lambda:(uploadFile(uploadFileLocation.get(), frame)))
    uploadButton.grid(row=1, column=2, padx=5, pady=5)

    #Select the file you would like to decrypt | File browser | Decrypt
    decryptFileLocation = StringVar()
    decryptFileLocation.set("Browse...")
    decryptLabel = Label(text="Select the file you would like to decrypt")
    decryptLabel.grid(row=2, column=0, sticky="W")

    decryptFileVar = StringVar()
    decryptFileVar.set("Browse...")
    decryptBrowseButton = Button(textvar=decryptFileVar, command= lambda:(browseFile(decryptFileVar, decryptFileLocation)))
    decryptBrowseButton.grid(row=2, column=1, padx=5, pady=5)

    decryptButton = Button(text="Decrypt File", command= lambda:(processDecryptButton(decryptFileLocation.get(), decryptFileVar.get(), config.getKey(), frame)))
    decryptButton.grid(row=2, column=2, padx=5, pady=5)

    #Select the file you would like to Encrypt | File Browser | Encrypt
    encryptFileLocation = StringVar()
    encryptFileLocation.set("")
    encryptLabel = Label(text="Select the File you would like to Encrypt")
    encryptLabel.grid(row=3, column=0, sticky="W")

    encryptFileVar = StringVar()
    encryptFileVar.set("Browse...")
    encryptBrowseButton = Button(textvar=encryptFileVar, command=lambda:(browseFile(encryptFileVar, encryptFileLocation)))
    encryptBrowseButton.grid(row=3, column=1, padx=5, pady=5)

    encryptButton = Button(text="Encrypt File", command= lambda: (processEncryptButton(encryptFileLocation.get(), encryptFileVar.get(), config.getKey(), frame)))
    encryptButton.grid(row=3, column=2, padx=5, pady=5)

    #Show buttons for user addition and removal
    addUserButton = Button(text="Add New User", command= lambda: processAddUserFrame(frame))
    addUserButton.grid(row=4, column=1, padx=5, pady=5)

    removeUserButton = Button(text="Remove Existing User", command= lambda: (processRemoveUserFrame(frame)))
    removeUserButton.grid(row=4, column=2, padx=5, pady=5)
示例#15
0
文件: views.py 项目: kevando/chewy
	def get(self,urlKey):
		try:
		    urlKey
		except NameError:
		    urlKey = ''

		if(urlKey==''):
			self.redirect('/')
		if(urlKey!=''):
			tid = int(urlKey)
			translation = Translation.get_by_id(tid)
			if translation != None:
				templateValues = {'placeholder':translation.wookie,'translation':translation.english,'key':config.getKey(),'BASE_URL':config.getRootURL()}
			else:
				templateValues = {'placeholder':'uhhhughh arrahhrrhhhh','translation':'This isn\'t the page you\'re looking for...','key':config.getKey(),'BASE_URL':config.getRootURL()}
		path = os.path.join(os.path.dirname(__file__), 'share.html')
		self.response.out.write(template.render(path, templateValues))
示例#16
0
    elif range > 16:
      steps = 256 # + 256 = 256^1
      dots = 2 # xxx.xxx.xxx.
    elif range > 8:
      steps = 65536 # + 65536 = 256^2
      dots = 1 # xxx.xxx.
    elif range > 0:
      steps = 16777216# + 16777216 256^3
      dots = 0 # xxx.
    else:
      return [] # never ban /0
    i = 0
    retVal = []
    while IPv4Address(ip+i*steps) in net:
      address = str(ip+i*steps)
      indexes = [j for j,x in enumerate(address) if x == '.']
      indexes.append(32) # Whole string
      endpoint = indexes[dots]
      if dots < 3: # trailing dot needs to be readded
        retVal.append(address[:endpoint]+'.')
      else:
        retVal.append(address[:endpoint])
      i =  i + 1
    return retVal

if __name__ == "__main__":
   from Hyperion import Hyperion
   hyp = Hyperion(config.getKey('ent-user'),config.getKey('ent-pass'))
   f = open('E:\\Hyperion\\tmp\\rangeban.txt', 'r')
   hyp.whois_rangeban(f.read(),'vpn tid=28764 lancom mass ban')   
   f.close()
示例#17
0
        games.append(id)
        debug('Added id :: '+str(id),1)
      debug('Index is:: '+str(index) + ' | '+str(id)+' : '+str(last_id),2)
      index = index + 100

# Start at https://entgaming.net/bans/games.php?start=0

# Mark last game id
# Check if last game id is after last known id
# If it is, keep incrememting url by 100 until it is not.

# https://entgaming.net/bans/game.php?id=4740840
# view-source:https://entgaming.net/bans/game.php?id=4740840?id=4740840

if __name__ == '__main__':
  auth = EntAdapter(config.getKey('ent-user'),config.getKey('ent-pass'))
  print(auth._postPage('https://entgaming.net/bans/',{}))
  #print(str(auth.getGames('Island Defense','4726776')))
  temp = auth._postPage('https://entgaming.net/bans/game.php?id=4740840',{})
  soup = BeautifulSoup(temp)
  tds = soup.findAll('td')
  users = []
  for i in range(0,math.ceil((len(tds)-17)/5)): #players
    users.append(
    {
      'userpage' : tds[16+5*i+0], #username
      'realm' : tds[16+5*i+2],
      'ip' : tds[16+5*i+1],
      'left' : tds[16+5*i+3],
      'left_reason' : tds[16+5*i+4]
    })
def getImage(country):
    HOME_PATH = os.path.dirname(os.path.realpath(__file__))
    API_KEY = config.getKey()
    GOOGLE_URL = ("http://maps.googleapis.com/maps/api/streetview?sensor=false&"
                  "size=640x640&key=" + API_KEY)
    IMG_PREFIX = "img_"
    IMG_SUFFIX = ".jpg"

    print "Loading borders"
    shape_file = HOME_PATH + "/TM_WORLD_BORDERS-0.3.shp"
    if not os.path.exists(shape_file):
        print("Cannot find " + shape_file + ". Please download it from "
              "http://thematicmapping.org/downloads/world_borders.php "
              "and try again.")
        sys.exit()

    sf = shapefile.Reader(shape_file)
    shapes = sf.shapes()

    print "Finding country"
    for i, record in enumerate(sf.records()):
        if record[2] == country.upper():
            print record[2], record[4]
            print shapes[i].bbox
            min_lon = shapes[i].bbox[0]
            min_lat = shapes[i].bbox[1]
            max_lon = shapes[i].bbox[2]
            max_lat = shapes[i].bbox[3]
            borders = shapes[i].points
            break

    print "Getting images"
    attempts, country_hits, imagery_hits, imagery_misses = 0, 0, 0, 0
    MAX_URLS = 25000
    IMAGES_WANTED = 1

    try:
        while(True):
            attempts += 1
            rand_lat = random.uniform(min_lat, max_lat)
            rand_lon = random.uniform(min_lon, max_lon)
            # print attempts, rand_lat, rand_lon
            # Is (lat,lon) inside borders?
            if point_inside_polygon(rand_lon, rand_lat, borders):
                print "  In country"
                country_hits += 1
                lat_lon = str(rand_lat) + "," + str(rand_lon)
                outfile = os.path.join(
                    HOME_PATH + '/images', IMG_PREFIX + 'test' + IMG_SUFFIX)
                url = GOOGLE_URL + "&location=" + lat_lon
                try:
                    urllib.urlretrieve(url, outfile)
                except KeyboardInterrupt:
                    sys.exit("exit")
                except:
                    pass
                if os.path.isfile(outfile):
                    print lat_lon
                    # get_color returns the main color of image
                    color = getcolor.get_color(outfile)
                    print color
                    if color[0] == '#e3e2dd' or color[0] == "#e3e2de":
                        print "    No imagery"
                        imagery_misses += 1
                        os.remove(outfile)
                    else:
                        print "    ========== Got one! =========="
                        imagery_hits += 1
                        if imagery_hits == IMAGES_WANTED:
                            break
                if country_hits == MAX_URLS:
                    break
    except KeyboardInterrupt:
        print "Keyboard interrupt"

    print "Attempts:\t", attempts
    print "Country hits:\t", country_hits
    print "Imagery misses:\t", imagery_misses
    print "Imagery hits:\t", imagery_hits

    return lat_lon
示例#19
0
def getImage(country):
    HOME_PATH = os.path.dirname(os.path.realpath(__file__))
    API_KEY = config.getKey()
    GOOGLE_URL = (
        "http://maps.googleapis.com/maps/api/streetview?sensor=false&"
        "size=640x640&key=" + API_KEY)
    IMG_PREFIX = "img_"
    IMG_SUFFIX = ".jpg"

    print "Loading borders"
    shape_file = HOME_PATH + "/TM_WORLD_BORDERS-0.3.shp"
    if not os.path.exists(shape_file):
        print(
            "Cannot find " + shape_file + ". Please download it from "
            "http://thematicmapping.org/downloads/world_borders.php "
            "and try again.")
        sys.exit()

    sf = shapefile.Reader(shape_file)
    shapes = sf.shapes()

    print "Finding country"
    for i, record in enumerate(sf.records()):
        if record[2] == country.upper():
            print record[2], record[4]
            print shapes[i].bbox
            min_lon = shapes[i].bbox[0]
            min_lat = shapes[i].bbox[1]
            max_lon = shapes[i].bbox[2]
            max_lat = shapes[i].bbox[3]
            borders = shapes[i].points
            break

    print "Getting images"
    attempts, country_hits, imagery_hits, imagery_misses = 0, 0, 0, 0
    MAX_URLS = 25000
    IMAGES_WANTED = 1

    try:
        while (True):
            attempts += 1
            rand_lat = random.uniform(min_lat, max_lat)
            rand_lon = random.uniform(min_lon, max_lon)
            # print attempts, rand_lat, rand_lon
            # Is (lat,lon) inside borders?
            if point_inside_polygon(rand_lon, rand_lat, borders):
                print "  In country"
                country_hits += 1
                lat_lon = str(rand_lat) + "," + str(rand_lon)
                outfile = os.path.join(HOME_PATH + '/images',
                                       IMG_PREFIX + 'test' + IMG_SUFFIX)
                url = GOOGLE_URL + "&location=" + lat_lon
                try:
                    urllib.urlretrieve(url, outfile)
                except KeyboardInterrupt:
                    sys.exit("exit")
                except:
                    pass
                if os.path.isfile(outfile):
                    print lat_lon
                    # get_color returns the main color of image
                    color = getcolor.get_color(outfile)
                    print color
                    if color[0] == '#e3e2dd' or color[0] == "#e3e2de":
                        print "    No imagery"
                        imagery_misses += 1
                        os.remove(outfile)
                    else:
                        print "    ========== Got one! =========="
                        imagery_hits += 1
                        if imagery_hits == IMAGES_WANTED:
                            break
                if country_hits == MAX_URLS:
                    break
    except KeyboardInterrupt:
        print "Keyboard interrupt"

    print "Attempts:\t", attempts
    print "Country hits:\t", country_hits
    print "Imagery misses:\t", imagery_misses
    print "Imagery hits:\t", imagery_hits

    return lat_lon
示例#20
0
    player['game_id'] = game_id
    player_db.insert(player)


  def addGame(self,game_id,game_name,date,duration,map,players):
    '''
    Unique :: game_id
    {
        game_id     :   1337
        game_name   :   Pro Game
        date        :   2014-12-1 18:56:00
        duration    :   13.4
        map         :   pro.w3x
    }
    For every game there will be corresponding player entries who were in the game
    '''
    game_db = self.db['games']
    game = {
      "game_id":game_id,
      "game name":game_name,
      "date":date,
      "duration":duration,
      "map":map
    }
    game_db.insert(game)
    for player in players:
      addPlayer(player,game_id)

if __name__ == "__main__":
  mongo = MongoAdapter(config.getKey('mongo-host'),config.getKey('mongo-port'),config.getKey('mongo-user'),config.getKey('mongo-pass'))
示例#21
0
def debug(message,level):
  if config.getKey('verbose') <= level:
    print(message)
示例#22
0
import config
import Image
import urllib
import os
import subprocess
import random_street_view
import random
import requests
import glob
import gifcreator
from twython import Twython
from shutil import copyfile



CLAVE = config.getKey()
HOME_PATH = os.path.dirname(os.path.realpath(__file__))
PAISES = ["ARG","CHL","URY","PER","BOL","BRA","ECU","COL","ZAF","ISR","NZL","AUS","PHL","SGP","THA","KHM","TWN","BGD","LKA",'HKG','JPN','BTN','TUR','BGR','ROU','GRC','UKR','MKD','SRB','HRV','SVK','SVN','HUN','POL','CZE','LTU','LVA','EST','SWE','FIN','NOR','ITA','ESP','PRT','NLD','BEL','FRA','GBR','IRL','DNK','USA','MEX']
ELEGIDO = random.choice(PAISES)
TWITTER = config.getTwitterKeys()
print "El pais elegido es: " + ELEGIDO

def getImage():
    lat_lon = random_street_view.getImage(ELEGIDO)
    return lat_lon

def getAddress(lat_lon):
    URL_REVERSE = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat_lon + "&key=AIzaSyC7e8qywg4vWmaj7nJvEfSWRHOUdsiCp30&language=ES"
    response = requests.get(URL_REVERSE)
    data = response.json()
    return data['results'][0]['formatted_address']
示例#23
0
import config
import Image
import urllib
import os
import subprocess
import random_street_view
import random
import requests
import glob
import gifcreator
from twython import Twython
from shutil import copyfile

CLAVE = config.getKey()
HOME_PATH = os.path.dirname(os.path.realpath(__file__))
PAISES = [
    "ARG", "CHL", "URY", "PER", "BOL", "BRA", "ECU", "COL", "ZAF", "ISR",
    "NZL", "AUS", "PHL", "SGP", "THA", "KHM", "TWN", "BGD", "LKA", 'HKG',
    'JPN', 'BTN', 'TUR', 'BGR', 'ROU', 'GRC', 'UKR', 'MKD', 'SRB', 'HRV',
    'SVK', 'SVN', 'HUN', 'POL', 'CZE', 'LTU', 'LVA', 'EST', 'SWE', 'FIN',
    'NOR', 'ITA', 'ESP', 'PRT', 'NLD', 'BEL', 'FRA', 'GBR', 'IRL', 'DNK',
    'USA', 'MEX'
]
ELEGIDO = random.choice(PAISES)
TWITTER = config.getTwitterKeys()
print "El pais elegido es: " + ELEGIDO


def getImage():
    lat_lon = random_street_view.getImage(ELEGIDO)
    return lat_lon