Skip to content

Commit

Permalink
fix problems with local install #132
Browse files Browse the repository at this point in the history
1. Local install search python_r??.zip in Python3ForAndroid,
    must be fixed to search python3_r??.zip
2. Local install searching python_r??.zip was failed with
    multiple python_r??.zip with NullPointerException.

and gitbase.py automation fixed to remove suffix .git.
  • Loading branch information
kuri65536 committed Jan 21, 2017
1 parent fa65748 commit bbe2d45
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
// means of uninstalling as well. Import handling could well be a separate activity, too.
public class Python3Main extends PythonMain {

@Override
public String getPfxPython() {
return "python3";
}

@Override
protected InterpreterDescriptor getDescriptor() {
mDescriptor = new Python3Descriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public int getId() {
}
}

public String getPfxPython() {
return ""; // override by Python{|3}ForAndroid.
}

private String readFirstLine(File target) {
BufferedReader in;
String result;
Expand Down Expand Up @@ -861,9 +865,14 @@ protected void onProgressUpdate(String... values) {

class CheckLocalVersion extends CheckVersion {
int mWhich;
String pfxPython;
final String sfxPythonBin = "_r";
final String sfxPythonExt = "_extras_r";
final String sfxPythonScr = "_scripts_r";

CheckLocalVersion(PythonMain parent) {
super(parent);
pfxPython = parent.getPfxPython();
}

@Override
Expand All @@ -888,13 +897,16 @@ protected Boolean doInBackground(Integer... params) {
if (!fname.isFile()) { continue; }
if (!fname.canRead()) { continue; }

if (fname.getName().startsWith("python_r")) {
if (fname.getName().startsWith(pfxPython + sfxPythonBin)) {
Log.i("found for bin: " + fname.getName());
itps.add(fname);
}
if (fname.getName().startsWith("python_extras_r")) {
if (fname.getName().startsWith(pfxPython + sfxPythonExt)) {
Log.i("found for extras: " + fname.getName());
exts.add(fname);
}
if (fname.getName().startsWith("python_scripts_r")) {
if (fname.getName().startsWith(pfxPython + sfxPythonScr)) {
Log.i("found for scripts: " + fname.getName());
scrs.add(fname);
}
}
Expand All @@ -914,9 +926,9 @@ protected Boolean doInBackground(Integer... params) {
File ext = doSelectZip(exts, "External modules");
File scr = doSelectZip(scrs, "Sample scripts");

version = doExtractVersion(itp, "python_r");
extras = doExtractVersion(ext, "pyrhon_extras_r");
scripts = doExtractVersion(scr, "python_scripts_r");
version = doExtractVersion(itp, pfxPython + sfxPythonBin);
extras = doExtractVersion(ext, pfxPython + sfxPythonExt);
scripts = doExtractVersion(scr, pfxPython + sfxPythonScr);
publishProgress("Versions Updated");

parent.runOnUiThread(new Runnable() {
Expand All @@ -934,9 +946,10 @@ public File doSelectZip(ArrayList<File> seq, final String title) {
if (seq.size() < 2) {
return seq.get(0); // there is only one file, good case!
}
// BUG: not work well, 2017/01/17
// show users to select zip.
final CharSequence[] items = seq.toArray(new CharSequence[seq.size()]);
final CharSequence[] items = new CharSequence[seq.size()];
int n = 0;
for (File f: seq) {items[n++] = f.getName();}
parent.runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
public class PythonMain
extends com.googlecode.android_scripting.pythoncommon.PythonMain {

@Override
public String getPfxPython() {
return "python";
}

@Override
protected InterpreterDescriptor getDescriptor() {
mDescriptor = new PythonDescriptor();
Expand Down
7 changes: 5 additions & 2 deletions tools/gitbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def main_hg(drepo): # {{{1

for opt in cfg.options("paths"):
v = cfg.get("paths", opt)
if (v.startswith("git://") or
if not (v.startswith("git://") or
v.startswith("git+ssh://")):
return v # use 1st URL to git.
continue
if v.endswith(".git"):
v = v[:-4]
return v # use 1st URL to git.
return ""


Expand Down

0 comments on commit bbe2d45

Please sign in to comment.