import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;
class main {
public static void main(final String[] args) throws Exception {
for (Snippet s : iterate_printProgress(listDynModuleSnippets()))
if (isServerTranspiled(s.id)) { try {
transpileOnNewServer(s.id);
} catch (Throwable __e) { _handleException(__e); }}
}
static IterableIterator iterate_printProgress(final Collection l) {
return iff(new F0() {
int n = l(l), i;
Iterator it = iterator(l);
NotTooOften nto = onlyEverySecond();
public Object get() {
if (!it.hasNext()) return endMarker();
if (i > 0 && nto.yo()) print("Progress: " + i + "/" + n);
++i;
return it.next();
}
});
}
static List listDynModuleSnippets() {
return listSnippetsOfType(snippetType_dynModule());
}
static boolean isServerTranspiled(String snippetID) {
return hasServerDex(snippetID);
}
// default mode = "quick"
static Pair transpileOnNewServer(String snippetID) {
return transpileOnNewServer(snippetID, "quick");
}
static Pair transpileOnNewServer(long snippetID) {
return transpileOnNewServer(fsI(snippetID));
}
static Pair transpileOnNewServer(long snippetID, String mode) {
return transpileOnNewServer(fsI(snippetID), mode);
}
// mode = "quick", "medium", "fresh"
// result = pair(ok, answer)
static Pair transpileOnNewServer(String snippetID, String mode) { try {
print("Transpiling " + formatSnippetID(snippetID));
String url = "http://butter.botcompany.de/1018308/raw/" + psI(snippetID);
if (eqOneOf(mode, "medium", "fresh")) url += "?fresh=1";
String result = postPage(url, muricaCredentials());
print(result);
boolean ok = cic(htmlDecode(result), "Transpiled & uploaded");
return pair(ok, result);
} catch (Exception __e) { throw rethrow(__e); } }
static volatile PersistableThrowable _handleException_lastException;
static List _handleException_onException = synchroList(ll("printStackTrace2"));
static void _handleException(Throwable e) {
_handleException_lastException = persistableThrowable(e);
Throwable e2 = innerException(e);
if (e2.getClass() == RuntimeException.class && eq(e2.getMessage(), "Thread cancelled.") || e2 instanceof InterruptedException)
return;
for (Object f : cloneList(_handleException_onException)) try {
callF(f, e);
} catch (Throwable e3) {
printStackTrace2(e3); // not using pcall here - it could lead to endless loops
}
}
static Throwable printStackTrace2(Throwable e) {
// we go to system.out now - system.err is nonsense
print(getStackTrace2(e));
return e;
}
static void printStackTrace2() {
printStackTrace2(new Throwable());
}
static void printStackTrace2(String msg) {
printStackTrace2(new Throwable(msg));
}
// f: func -> A | endMarker
static IterableIterator iff(Object f) {
return iteratorFromFunction_withEndMarker(f);
}
static IterableIterator iff(F0 f) {
return iteratorFromFunction_withEndMarker(f);
}
static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(boolean[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(short[] a) { return a == null ? 0 : a.length; }
static int l(long[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(double[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
static long l(File f) { return f == null ? 0 : f.length(); }
static int l(Object o) {
return o == null ? 0
: o instanceof String ? l((String) o)
: o instanceof Map ? l((Map) o)
: o instanceof Collection ? l((Collection) o)
: o instanceof Object[] ? l((Object[]) o)
: o instanceof boolean[] ? l((boolean[]) o)
: o instanceof byte[] ? l((byte[]) o)
: o instanceof char[] ? l((char[]) o)
: o instanceof short[] ? l((short[]) o)
: o instanceof int[] ? l((int[]) o)
: o instanceof float[] ? l((float[]) o)
: o instanceof double[] ? l((double[]) o)
: o instanceof long[] ? l((long[]) o)
: (Integer) call(o, "size");
}
static Iterator iterator(Iterable c) {
return c == null ? emptyIterator() : c.iterator();
}
static NotTooOften onlyEverySecond() {
return new NotTooOften(1000);
}
static Object endMarker() {
return iteratorFromFunction_endMarker;
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
//static int print_maxLineLength = 0; // 0 = unset
static boolean print_silent; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal