Exemple #1
0
def remove(file, language='en', **kwargs):
    '''Remove master file from a remote project. This will remove the master file (and related translations). Local file is not removed.'''
    repo = Repository()

    if repo.master_exists(file):
        username = kwargs.get('username')
        password = kwargs.get('password')

        if username == '' or password == '':
            username, password = prompt_userpw()

        mf = GLMasterFile(
            GLProject(repo.get_project_name(), username, password),
            repo.relative_to_root(file), file, None)

        try:
            mf.remove()
            repo.rm_master(file)
            print "File %s removed successfully." % repo.relative_path(
                repo.file_path(file))
        except GLException as e:
            print "Unable to remove file from server: " + str(e)
    else:
        print "Couldn't find a file %s" % repo.relative_path(
            repo.file_path(file))
Exemple #2
0
def map_master(oldFile, newFile, **kwargs):
    '''Map existing master file on server to new a location on your local repository. This also changes the filename on server-side to match your local directory structure.'''

    repo = Repository()

    username = kwargs.get('username')
    password = kwargs.get('password')

    if username == '' or password == '':
        username, password = prompt_userpw()

    mf = GLMasterFile(GLProject(repo.get_project_name(), username, password),
                      repo.relative_to_root(oldFile),
                      repo.relative_path(repo.file_path(oldFile)), None)

    if not mf.isAvailableRemotely():
        print "Error: File " + oldFile + " is not available on the server."
        return

    try:
        if repo.rename_master_file(oldFile, newFile):
            mf.rename(newFile, repo.relative_path(repo.file_path(newFile)))
            repo.commit(
            )  # Commit the rename to local repo after successful request to server

            translations = GLTranslations(
                GLProject(repo.get_project_name(), username, password))
            trlist = translations.list()
            repo.save_status(trlist)

            print "Successfully mapped master %s => %s" % (oldFile, newFile)
        else:
            print "Error when mapping master file."
    except EnvironmentError as err:
        print err
def map_master(oldFile, newFile, **kwargs):
    '''Map existing master file on server to new a location on your local repository. This also changes the filename on server-side to match your local directory structure.'''
    
    repo = Repository()

    username = kwargs.get('username')
    password = kwargs.get('password')
  
    if username == '' or password == '':
        username, password = prompt_userpw()


    mf = GLMasterFile(GLProject(repo.get_project_name(), username, password), repo.relative_to_root(oldFile), repo.relative_path(repo.file_path(oldFile)), None)

    if not mf.isAvailableRemotely():
        print "Error: File " + oldFile + " is not available on the server."
        return

    try:
        if repo.rename_master_file(oldFile, newFile):
            mf.rename(newFile, repo.relative_path(repo.file_path(newFile)))
            repo.commit() # Commit the rename to local repo after successful request to server

            translations = GLTranslations(GLProject(repo.get_project_name(), username, password))
            trlist = translations.list()
            repo.save_status(trlist)

            print "Successfully mapped master %s => %s" % (oldFile, newFile)
        else:
            print "Error when mapping master file."
    except EnvironmentError as err:
        print err
Exemple #4
0
def push(**kwargs):
    '''Push changed master files to server'''

    repo = Repository()

    files = repo.get_changed_files()

    if len(files) == 0:
        print "#"
        print "# Nothing to push"
        print "#"
        sys.exit(1)
    else:
        print "#\n# Changes not pushed:\n#"
        for file in files:
            print "#\tmodified: %s" % file
        print "#\n"

    username = kwargs.get('username')
    password = kwargs.get('password')

    if username == '' or password == '':
        username, password = prompt_userpw()

    error = False

    for file in files:
        platformId = autodetect_fileformat(repo.file_path(file))

        if platformId is None:
            print "# Couldn't detect file format for file %s, please define it manually" % file
            return

        mf = GLMasterFile(
            GLProject(repo.get_project_name(), username, password),
            repo.relative_to_root(file), file, platformId)

        try:
            mf.push()
            repo.touch_master(file)
        except GLException as e:
            error = True
            print e.message

    if not error:
        print "# Done"
    sys.exit(0)
def push(**kwargs):
    '''Push changed master files to server'''
    
    repo = Repository();
    
    files = repo.get_changed_files()
    
    if len(files) == 0:
        print "#"
        print "# Nothing to push"
        print "#"
        sys.exit(1)
    else:
        print "#\n# Changes not pushed:\n#"
        for file in files:
            print "#\tmodified: %s" % file
        print "#\n"
  
    username = kwargs.get('username')
    password = kwargs.get('password')
  
    if username == '' or password == '':
        username, password = prompt_userpw()
    
    error = False

    for file in files:
        platformId = autodetect_fileformat(repo.file_path(file))
        
        if platformId is None:
            print "# Couldn't detect file format for file %s, please define it manually" % file
            return
        
        mf = GLMasterFile(GLProject(repo.get_project_name(), username, password), repo.relative_to_root(file), file, platformId)

        try:
            mf.push()
            repo.touch_master(file)
        except GLException as e:
            error = True
            print e.message
        
    if not error:
        print "# Done"
    sys.exit(0)
def remove(file, language='en', **kwargs):
    '''Remove master file from a remote project. This will remove the master file (and related translations). Local file is not removed.'''
    repo = Repository()

    if repo.master_exists(file):
        username = kwargs.get('username')
        password = kwargs.get('password')
      
        if username == '' or password == '':
            username, password = prompt_userpw()
       
        mf = GLMasterFile(GLProject(repo.get_project_name(), username, password), repo.relative_to_root(file), file, None)
        
        try:
            mf.remove()
            repo.rm_master(file)
            print "File %s removed successfully." % repo.relative_path(repo.file_path(file))
        except GLException as e:
            print "Unable to remove file from server: " + str(e)
    else:
        print "Couldn't find a file %s" % repo.relative_path(repo.file_path(file))