Esempio n. 1
0
def create_profile(user_profile):
    settings = Gio.Settings('org.sugarlabs.user')

    settings.set_string('nick', user_profile.nickname)

    colors = user_profile.colors
    if colors is None:
        colors = XoColor()
    settings.set_string('color', colors.to_string())

    if user_profile.gender is not None:
        settings.set_string('gender', user_profile.gender)
    else:
        settings.set_string('gender', '')

    settings.set_int('birth-timestamp',
                     calculate_birth_timestamp(user_profile.age))
    # settings.sync()

    # DEPRECATED
    from gi.repository import GConf
    client = GConf.Client.get_default()

    client.set_string('/desktop/sugar/user/nick', user_profile.nickname)

    client.set_string('/desktop/sugar/user/color', colors.to_string())

    if user_profile.gender is not None:
        client.set_string('/desktop/sugar/user/gender', user_profile.gender)

    client.set_int('/desktop/sugar/user/birth_timestamp',
                   calculate_birth_timestamp(user_profile.age))
    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken',
                        keypath, keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    logging.debug("Generating user keypair")

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = subprocess.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)

    logging.debug("User keypair generated")
Esempio n. 2
0
def create_profile(user_profile):
    settings = Gio.Settings('org.sugarlabs.user')

    if user_profile.nickname in [None, '']:
        nick = settings.get_string('nick')
        if nick is not None:
            logging.debug('recovering old nickname %s' % (nick))
            user_profile.nickname = nick
    settings.set_string('nick', user_profile.nickname)

    colors = user_profile.colors
    if colors is None:
        colors = XoColor()
    settings.set_string('color', colors.to_string())

    genderpicker.save_gender(user_profile.gender)

    agepicker.save_age(user_profile.age)

    # DEPRECATED
    from gi.repository import GConf
    client = GConf.Client.get_default()

    client.set_string('/desktop/sugar/user/nick', user_profile.nickname)

    client.set_string('/desktop/sugar/user/color', colors.to_string())

    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken', keypath,
                        keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    logging.debug("Generating user keypair")

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)

    logging.debug("User keypair generated")
Esempio n. 3
0
def create_profile(user_profile):
    settings = Gio.Settings('org.sugarlabs.user')

    if user_profile.nickname in [None, '']:
        nick = settings.get_string('nick')
        if nick is not None:
            logging.debug('recovering old nickname %s' % (nick))
            user_profile.nickname = nick
    settings.set_string('nick', user_profile.nickname)

    colors = user_profile.colors
    if colors is None:
        colors = XoColor()
    settings.set_string('color', colors.to_string())

    genderpicker.save_gender(user_profile.gender)

    agepicker.save_age(user_profile.age)

    # DEPRECATED
    from gi.repository import GConf
    client = GConf.Client.get_default()

    client.set_string('/desktop/sugar/user/nick', user_profile.nickname)

    client.set_string('/desktop/sugar/user/color', colors.to_string())

    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken',
                        keypath, keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    logging.debug("Generating user keypair")

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)

    logging.debug("User keypair generated")
Esempio n. 4
0
def create_profile(name, color=None):
    if not color:
        color = XoColor()

    client = GConf.Client.get_default()
    client.set_string('/desktop/sugar/user/nick', name)
    client.set_string('/desktop/sugar/user/color', color.to_string())
    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    import commands
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken', keypath,
                        keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    logging.debug("Generating user keypair")

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)

    logging.debug("User keypair generated")
Esempio n. 5
0
def create_profile(name, color=None):
    if not color:
        color = XoColor()

    client = GConf.Client.get_default()
    client.set_string('/desktop/sugar/user/nick', name)
    client.set_string('/desktop/sugar/user/color', color.to_string())
    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    import commands
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken',
                        keypath, keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    logging.debug("Generating user keypair")

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)

    logging.debug("User keypair generated")
def invX(x, id):  # noqa
    return float(x) * h / GLYPH_BOX[id]['height']


def invY(y, id):  # noqa
    return h - float(y) * h / GLYPH_BOX[id]['height'] - b


# #########
# User Info
# #########

settings = Gio.Settings('org.sugarlabs.user')
color =\
    XoColor(settings.get_string('color'))
USER_COLOR = color.to_string().split(',')

# ###########
# Screen Info
# ###########

SCREEN = Gdk.Screen.get_default()
SCREEN_WIDTH = SCREEN.get_width()
SCREEN_HEIGHT = SCREEN.get_height()

# ######################
# Widget Styles/Settings
# ######################

# General
Esempio n. 7
0
def invX(x, id):  # noqa
    return float(x) * h / GLYPH_BOX[id]['height']


def invY(y, id):  # noqa
    return h - float(y) * h / GLYPH_BOX[id]['height'] - b

# #########
# User Info
# #########

client = GConf.Client.get_default()
color =\
    XoColor(client.get_string('/desktop/sugar/user/color'))
USER_COLOR = color.to_string().split(',')

# ###########
# Screen Info
# ###########

SCREEN = Gdk.Screen.get_default()
SCREEN_WIDTH = SCREEN.get_width()
SCREEN_HEIGHT = SCREEN.get_height()

# ######################
# Widget Styles/Settings
# ######################

# General