def create_rsync_share(name, path, comment, list, readonly, uid, gid): try: db_path, err = common.get_db_path() if err: raise Exception(err) check, err = db.read_single_row( db_path, "select * from rsync_shares where name='%s'" % name) if check: raise Exception("Share already exists.Use a different share name") cmd_list = [] cmd = [ "insert into rsync_shares (name,path,comment,list,readonly,uid,gid) values(?,?,?,?,?,?,?)", (name, path, comment, list, readonly, uid, gid) ] cmd_list.append(cmd) ret, err = db.execute_iud(db_path, cmd_list) if err: raise Exception(err) config, err = _generate_rsync_config() if err: raise Exception(err) except Exception, e: return False, 'Error saving rsync config settings : %s' % str(e)
def main(): # Default in and out directories directories = common.initialise_subdirs(['assets', 'big_image', 'zoomify_tiles']) parser = argparse.ArgumentParser(description='Make big map image from screenshots and connection data') #Parse arguments parser.add_argument('-o', '--output', default=None, help='Output direcory. Default is "../'+directories[2]+'"') parser.add_argument('-p', '--palette', default='default', help='Color palette and format options to use') parser.add_argument('-r', '--region', help='Region to render - default is all') parser.add_argument('-s', '--scale', default=1.0, type=float, help='Scale final image (1.0 is actual, 0.5 is half size)') parser.add_argument('-k', '--k-value', default=3.0, type=float, help='Spring constant passed to the Fruchterman-Reingold algorithm. Changes network shape') parser.add_argument('-i', '--iterations', default=50, type=int, help='Number of iterations for Fruchterman-Reingold algorithm, default is 50') parser.add_argument('-v', '--network-overlap', default=3.0, type=float, help='Increases spacing between nodes (after position optimisation)') parser.add_argument('--world', default=False, action='store_true', help='Draw the whole world, starting with the region specified by -r (or first region chosen)') args = parser.parse_args() OUTPUT_PATH = os.path.realpath(os.path.join(os.getcwd(), directories[2])) if args.output: OUTPUT_PATH = os.path.realpath(os.path.join(os.getcwd(), args.output)) # Take location of screenshot and xth line, and return position. If x = 0 returns scrn region_keys = [] if args.region: region_keys = [common.lookup_region_key(args.region)] else: conn = sqlite3.connect(common.get_db_path()) region_cursor = conn.cursor() region_cursor.execute('SELECT key, name FROM regions ORDER BY key ASC') regions = region_cursor.fetchall() # save region maps separately for region in regions: region_keys.append(region) for region_key in region_keys: big_image_path = generate.draw_map(region_key[0], palette_name=args.palette, image_scale_factor=args.scale, network_contraction=args.k_value, network_overlap=args.network_overlap, draw_world=args.world, iterations=args.iterations ) if big_image_path: zoomify.zoomify(big_image_path, OUTPUT_PATH) else: print '!', region_key[1], 'failed to generate'
def load_shares_list(): l = [] try: db_path, err = common.get_db_path() if err: raise Exception(err) l, err = db.read_multiple_rows(db_path, 'select * from rsync_shares') if err: raise Exception(err) except Exception, e: return None, 'Error loading RSYNC shares list : %s' % str(e)
def get_rsync_share_details(name): share = None try: db_path, err = common.get_db_path() if err: raise Exception(err) share, err = db.read_single_row( db_path, "select * from rsync_shares where name='%s'" % name) if not share: raise Exception("Specified share not found ") except Exception, e: return False, 'Error deleting the share: %s' % str(e)
def delete_rsync_share(name): try: db_path, err = common.get_db_path() if err: raise Exception(err) cmd_list = [] check, err = db.read_single_row( db_path, "select * from rsync_shares where name='%s'" % name) if not check: raise Exception("Specified share not found ") cmd = ["delete from rsync_shares where name='%s'" % name] cmd_list.append(cmd) ret, err = db.execute_iud(db_path, cmd_list) if err: raise Exception(err) config, err = _generate_rsync_config() if err: raise Exception(err) except Exception, e: return False, 'Error deleting the share: %s' % str(e)
def main(): # Default in and out directories directories = common.initialise_subdirs( ['assets', 'big_image', 'zoomify_tiles']) parser = argparse.ArgumentParser( description='Make big map image from screenshots and connection data' ) #Parse arguments parser.add_argument('-o', '--output', default=None, help='Output direcory. Default is "../' + directories[2] + '"') parser.add_argument('-p', '--palette', default='default', help='Color palette and format options to use') parser.add_argument('-r', '--region', help='Region to render - default is all') parser.add_argument( '-s', '--scale', default=1.0, type=float, help='Scale final image (1.0 is actual, 0.5 is half size)') parser.add_argument( '-k', '--k-value', default=3.0, type=float, help= 'Spring constant passed to the Fruchterman-Reingold algorithm. Changes network shape' ) parser.add_argument( '-i', '--iterations', default=50, type=int, help= 'Number of iterations for Fruchterman-Reingold algorithm, default is 50' ) parser.add_argument( '-v', '--network-overlap', default=3.0, type=float, help='Increases spacing between nodes (after position optimisation)') parser.add_argument( '--world', default=False, action='store_true', help= 'Draw the whole world, starting with the region specified by -r (or first region chosen)' ) args = parser.parse_args() OUTPUT_PATH = os.path.realpath(os.path.join(os.getcwd(), directories[2])) if args.output: OUTPUT_PATH = os.path.realpath(os.path.join(os.getcwd(), args.output)) # Take location of screenshot and xth line, and return position. If x = 0 returns scrn region_keys = [] if args.region: region_keys = [common.lookup_region_key(args.region)] else: conn = sqlite3.connect(common.get_db_path()) region_cursor = conn.cursor() region_cursor.execute('SELECT key, name FROM regions ORDER BY key ASC') regions = region_cursor.fetchall() # save region maps separately for region in regions: region_keys.append(region) for region_key in region_keys: big_image_path = generate.draw_map( region_key[0], palette_name=args.palette, image_scale_factor=args.scale, network_contraction=args.k_value, network_overlap=args.network_overlap, draw_world=args.world, iterations=args.iterations) if big_image_path: zoomify.zoomify(big_image_path, OUTPUT_PATH) else: print '!', region_key[1], 'failed to generate'
from PIL import Image, ImageDraw, ImageFont import os import sqlite3 import networkx as nx import math import sys import warnings import argparse import xml.etree.ElementTree as ET import common subdir_names = ['assets', 'big_image'] directories = common.initialise_subdirs(subdir_names) DB_LOCATION = common.get_db_path() MODE = (1, 0) ''' MODE = (a, b) a: 0=width, 1=depth (order in which initial positions are calculated) ''' # even numbers are best LABEL_IMAGE_DIR = os.path.join(directories[0], 'labels') MISSING_SCRN_OVERLAY_PATH = os.path.join(directories[0], 'misc', 'rain_mask.png') TRANSPARENT_PIXEL_PATH = os.path.join(directories[0], 'misc', 'semi.png') def region_property(region_key, property): conn = sqlite3.connect(DB_LOCATION) region_cursor = conn.cursor()
def __init__(self): self.conn = sqlite3.connect(common.get_db_path()) self.c = self.conn.cursor() self.check_tables() self.exter = self.unpickle()
from PIL import Image, ImageDraw, ImageFont import os import sqlite3 import networkx as nx import math import sys import warnings import argparse import xml.etree.ElementTree as ET import common subdir_names = ['assets', 'big_image'] directories = common.initialise_subdirs(subdir_names) DB_LOCATION = common.get_db_path() MODE = (1, 0) ''' MODE = (a, b) a: 0=width, 1=depth (order in which initial positions are calculated) ''' # even numbers are best LABEL_IMAGE_DIR = os.path.join(directories[0], 'labels') MISSING_SCRN_OVERLAY_PATH = os.path.join(directories[0], 'misc', 'rain_mask.png') TRANSPARENT_PIXEL_PATH = os.path.join(directories[0], 'misc', 'semi.png') def region_property(region_key, property):