2012-05-28 24 views
6

In version.py c'è un metodo get_git_version() quando eseguo ./manage.py runserver questo errore viene generato dal version.py file diget_git_version non riesce a trovare il numero di versione

sollevare ValueError ("Non riesci a trovare il numero di versione!")

def get_git_version(abbrev=4): 
    # Read in the version that's currently in RELEASE-VERSION. 

    release_version = read_release_version() 

    # First try to get the current version using "git describe". 

    version = call_git_describe(abbrev) 

    # If that doesn't work, fall back on the value that's in 
    # RELEASE-VERSION. 

    if version is None: 
     version = release_version 

    # If we still don't have anything, that's an error. 

    if version is None: 
     raise ValueError("Cannot find the version number!") 

    # If the current version is different from what's in the 
    # RELEASE-VERSION file, update the file to be current. 

    if version != release_version: 
     write_release_version(version) 

    # Finally, return the current version. 

    return version 


def read_release_version(): 
    try: 
     f = open("RELEASE-VERSION", "r") 

     try: 
      version = f.readlines()[0] 
      return version.strip() 

     finally: 
      f.close() 
    except: 
     return None 
+0

def read_release_version(): prova: f = open ("Release-VERSION", "r") prova: version = f.readlines() [0] ritorno version.strip() infine: f.close() eccetto: return Nessuno –

+1

Controllare il percorso per il file 'RELEASE-VERSION'. Controlla anche allegando l'estensione del file durante l'apertura, come 'RELEASE-VERSION.txt'. –

risposta

2

Questo script prevede un numero di versione da un tag git annotated (call_git_describe()) o dall'individuazione del numero di versione in un file denominato RELEASE-VERSION. Fallisce perché nessuna di queste due cose viene trovata, quindi risolverne una.

Esegui questo nel progetto per creare annotato tag per la corrente commettere:

git tag 1.0 -m "this is version 1.0" 

tendo a preferire codifica per la gestione delle versioni, ma la versione in un file di testo è anche un bene, YMMV.

Problemi correlati