Skip to content

Commit

Permalink
Use "mv" to move directories
Browse files Browse the repository at this point in the history
- Also added in some basic error logging
- Version update
- Fix date
  • Loading branch information
kjlaw89 committed Jun 13, 2018
1 parent a6c47dc commit 9fbe8a8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<img src="https://img.shields.io/badge/License-GPL--3.0-blue.svg">
</a>
<a href="https://github.com/kjlaw89/archetype/releases">
<img src="https://img.shields.io/badge/Release-v%201.0.0-orange.svg">
<img src="https://img.shields.io/badge/Release-v%201.0.2-orange.svg">
</a>
</p>

Expand Down
5 changes: 5 additions & 0 deletions data/com.github.kjlaw89.archetype.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
</ul>
</description>
<releases>
<release version="1.0.2" date="2018-06-12">
<description>
<p>Changed method for moving temp directory and added in basic error logging</p>
</description>
</release>
<release version="1.0.1" date="2018-06-04">
<description>
<p>Updated description and colors</p>
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.kjlaw89.archetype (1.0.2) xenial; urgency=low

* Update to fix moving temp directory and basic error logging

-- KJ Lawrence <[email protected]> Tue, 12 Jun 2018 23:45:00 -0500

com.github.kjlaw89.archetype (1.0.0) xenial; urgency=low

* Initial Release
Expand Down
12 changes: 12 additions & 0 deletions src/controllers/AppController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,19 @@ namespace App.Controllers {
var directory = File.new_for_path (template.directory);
Granite.Services.System.open (directory);
quit ();
return;
}

this.app_view.error_label.label = "Unable to create project";
var dialog = new Granite.MessageDialog.with_image_from_icon_name (
"Unable to create project",
template.error,
"dialog-error",
Gtk.ButtonsType.CLOSE
);

dialog.run ();
dialog.destroy ();
}
}
}
43 changes: 22 additions & 21 deletions src/models/Template.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace App.Models {
public class Template {

private App.Views.AppView view;
public string error { get; private set; default = ""; }

public string author { get; set; }
public string author_email { get; set; }
Expand Down Expand Up @@ -104,7 +105,8 @@ namespace App.Models {
return true;
}
catch (Error e) {
warning ("Unable to delete temporary files " + export_path +", "+ tar_path);
error = "Unable to delete temporary files " + export_path +", "+ tar_path;
warning (error);
}

return false;
Expand All @@ -123,12 +125,14 @@ namespace App.Models {
// Attempt to load the template resource
try {
if (!template_file.load_contents (null, out data, null)) {
warning ("Unable to load template resource");
error = "Unable to load template resource";
warning (error);
return false;
}
}
catch (Error e) {
warning ("Unable to load resource " + e.message);
error = "Unable to load resource " + e.message;
warning (error);
return false;
}

Expand All @@ -140,7 +144,8 @@ namespace App.Models {
output.write_all (data, null);
}
catch (Error e) {
warning ("Unable to create archive in /tmp " + e.message);
error = "Unable to create archive in /tmp " + e.message;
warning (error);
return false;
}

Expand All @@ -150,7 +155,8 @@ namespace App.Models {
Process.spawn_command_line_sync ("tar -xzf "+ tar_path +" -C "+ export_path);
}
catch (Error e) {
warning ("Unable to unzip archive in /tmp " + e.message);
error = "Unable to unzip archive in /tmp " + e.message;
warning (error);
return false;
}

Expand Down Expand Up @@ -223,12 +229,14 @@ namespace App.Models {

try {
if (!license_preamble_file.load_contents (null, out license_preamble_data, null)) {
warning ("Unable to load license preamble resource");
error = "Unable to load license preamble resource";
warning (error);
return false;
}
}
catch (Error e) {
warning ("Unable to get license preamble " + e.message);
error = "Unable to get license preamble " + e.message;
warning (error);
return false;
}

Expand Down Expand Up @@ -272,23 +280,16 @@ namespace App.Models {
initialize_git (export_path);
}

// Move directory
var source_dir = File.new_for_path (export_path);
var dest_dir = File.new_for_path (directory);
// Move directory
string stdout;
string stderr;
Process.spawn_command_line_sync ("mv \""+ export_path +"\" \""+ directory + "\"", out stdout, out stderr);

try {
if (!source_dir.move (dest_dir, FileCopyFlags.NONE)) {
warning ("Unable to move temp directory to " + directory);
clean (rdnn);
return false;
}
}
catch (Error e) {
warning ("Unable to move temp directory to "+ directory +" - "+ e.message);
clean (rdnn);
if (stderr.length > 0) {
error = "Unable to move temp directory to "+ directory +" - "+ stderr;
warning (error);
return false;
}


// Clean up after the build process (only the .tar.gz should be left)
clean (rdnn);
Expand Down
6 changes: 5 additions & 1 deletion src/views/AppView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace App.Views {
public Gtk.FileChooserButton directory_button { get; private set; }
public Gtk.Label directory_executable_label { get; private set; }
public Gtk.Entry domain_entry { get; private set; }
public Gtk.Label error_label { get; private set; }
public Gtk.Entry exec_entry { get; private set; }
public Gtk.Label executable_label { get; private set; }
public Gtk.Button generate_button { get; private set; }
Expand Down Expand Up @@ -134,6 +135,9 @@ namespace App.Views {
back ();
});

error_label = new Gtk.Label (null);
error_label.get_style_context ().add_class ("error");

var action_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
action_buttons_box.halign = Gtk.Align.END;
action_buttons_box.add (back_button);
Expand All @@ -143,11 +147,11 @@ namespace App.Views {
var buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
buttons_box.hexpand = true;
buttons_box.margin_top = 24;
buttons_box.add (error_label);
buttons_box.add (action_buttons_box);

this.add (stack_view);
this.add (buttons_box);


stage = "project";
toggle_buttons ();
Expand Down

0 comments on commit 9fbe8a8

Please sign in to comment.