Changeset 15316


Ignore:
Timestamp:
06/22/13 10:58:18 (12 years ago)
Author:
Eric.Larour
Message:

CHG: new upload and download capability. Handy when trying to save a model on server remotely.
This also allows to keep a link between the uploaded model and the current model, which is only
an empty shell to the uploadded model. When you need the full model, you download it.

Location:
issm/trunk-jpl/src/m/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/model/model.m

    r15106 r15316  
    12011201                        ylim([min(obj.mesh.y) max(obj.mesh.y)])
    12021202                end % }}}
     1203                function md=upload(md) % {{{
     1204                %the goal of this routine is to upload the model onto a server, and to empty it.
     1205                %So first, save the model with a unique name and upload the file to the server:
     1206                random_part=fix(rand(1)*10000);
     1207                id=[md.miscellaneous.name '-' regexprep(datestr(now),'[^\w'']','') '-' num2str(random_part)  '-' getenv('USER') '-' oshostname() '.upload'];
     1208                eval(['save ' id ' md']);
     1209
     1210                %Now, upload the file:
     1211                issmscpout(md.settings.upload_server,md.settings.upload_path,md.settings.upload_login,md.settings.upload_port,{id},1);
     1212
     1213                %Now, empty this model of everything except settings, and record name of file we just uploaded!
     1214                settings_back=md.settings;
     1215                md=model();
     1216                md.settings=settings_back;
     1217                md.settings.upload_filename=id;
     1218
     1219                %get locally rid of file that was uploaded
     1220                eval(['delete ' id]);
     1221
     1222
     1223                end % }}}
     1224                function md=download(md) % {{{
     1225               
     1226                %the goal of this routine is to download the internals of the current model from a server, because
     1227                %this model is empty, except for the settings which tell us where to go and find this model!
     1228               
     1229                %Download the file:
     1230                issmscpin(md.settings.upload_server, md.settings.upload_login, md.settings.upload_port, md.settings.upload_path, {md.settings.upload_filename});
     1231
     1232                name=md.settings.upload_filename;
     1233
     1234                %Now, load this model:
     1235                md=loadmodel(md.settings.upload_filename);
     1236
     1237                %get locally rid of file that was downloaded
     1238                eval(['delete ' name]);
     1239
     1240                end % }}}
    12031241        end
    12041242 end
  • issm/trunk-jpl/src/m/classes/settings.m

    r15131 r15316  
    1111                output_frequency    = 0;
    1212                waitonlock          = 0;
     13                upload_server       = '';
     14                upload_path         = '';
     15                upload_login        = '';
     16                upload_port         = 0;
     17                upload_filename     = '';
     18
    1319        end
    1420        methods
     
    4046                        %0 to deactivate
    4147                        obj.waitonlock=Inf;
     48               
     49                        %upload options:
     50                        upload_port         = 0;
     51
    4252                end % }}}
    4353                function md = checkconsistency(obj,md,solution,analyses) % {{{
     
    5868                        fielddisplay(obj,'output_frequency','frequency at which results are saved in all solutions with multiple time_steps');
    5969                        fielddisplay(obj,'waitonlock','maximum number of minutes to wait for batch results (NaN to deactivate)');
     70                        fielddisplay(obj,'upload_server','server hostname where model should be uploaded');
     71                        fielddisplay(obj,'upload_path','path on server where model should be uploaded');
     72                        fielddisplay(obj,'upload_login','server login');
     73                        fielddisplay(obj,'upload_port','port login (default is 0)');
     74                        fielddisplay(obj,'upload_filename','unique id generated when uploading the file to server');
    6075
    6176                end % }}}
Note: See TracChangeset for help on using the changeset viewer.