<commit_before>#!/bin/bash
TimeStart=$(date +%s);

# BasketBuild Upload Credentials
export UploadFTP="basketbuild.com";
export UploadServer='s.basketbuild.com/webupload';
export UploadUserName='Username.s';
export UploadPassword='';
export UploadFolder='Path/To/Folder';

# Create  ~/.bash_android.basketbuild.**name**.rc with the exports to override the credentials
RemoteVariant="${3}";
if [ ! -z "${RemoteVariant}" ] && [ -f ~/.bash_android.basketbuild.${RemoteVariant}.rc ]; then
  source ~/.bash_android.basketbuild.${RemoteVariant}.rc;
elif [ -f ~/.bash_android.basketbuild.main.rc ]; then
  source ~/.bash_android.basketbuild.main.rc;
fi;

# Variables
SendFile="${1}";
UploadFolder="${2:-Development}";

# Notify and verify the upload
echo '';
echo -e " \e[1;33m[ Uploading to the server - User '${UploadUserName}' - Path '${UploadFolder}' ]\e[0m";
echo '';
if [ ! -z "${SendFile}" ] && [ -f "${SendFile}" ] && [ ! -z "${UploadPassword}" ]; then

  # File variables
  SendFileName=$(basename "${SendFile}");
  SendFileExt=${SendFileName##*.};
  SendFileSize=$(stat -c "%s" "${SendFile}");
  SendFileType='';

  # Uploading a zip
  if [[ "${SendFileExt}" =~ 'zip' ]]; then
    SendFileType='application/zip';
  fi;

  # Notify the file name
  echo "   File '$(basename ${SendFile})' uploading...";
  echo '';

  # Upload to BasketBuild through FTP
  ncftpput -R -v -t 10 \
           -u "${UploadUserName}" \
           -p "${UploadPassword}" \
           ${UploadFTP} \
           ${UploadFolder} \
           ${SendFile};

  # Detect failed FTP upload
  if [ ${?} -ne 0 ]; then

    # Fallback to WebUI upload
    notify-send "Failed uploading through FTP...";
    echo '';
    echo '   Failed uploading through FTP. Falling back to WebUI upload...';
    echo '';

    # Login to BasketBuild
    curl -L -# --dump-header .headers \
            -F "ftp_user=${UploadUserName}" \
            -F "ftp_pass=${UploadPassword}" \
            -F "openFolder=~${UploadFolder}" \
            -F "ip_check=1" \
            -F "login=1" \
            -F "login_save=1" \
            -F "submit=Login" \
            "https://${UploadServer}/" > /dev/null;

    # Upload to BasketBuild through WebUI
    curl -X POST -L -# --progress-bar -b .headers \
            -H "Cache-Control: no-cache" \
            -H "X-Filename: ${SendFileName}" \
            -H "X-Requested-With: XMLHttpRequest" \
            -H "X-File-Size: ${SendFileSize}" \
            -H "X-File-Type: ${SendFileType}" \
            -H "Content-Type: multipart/form-data" \
            --data-binary @"${SendFile}" \
            -o .uploadoutputs \
            "https://${UploadServer}/?ftpAction=upload&filePath=";

  fi;

  # Upload done
  echo '';
  echo -e "  \e[1;32mDownload :\e[0m https://basketbuild.com/filedl/devs?dev=${UploadUserName:0:-2}&dl=${UploadUserName:0:-2}/${UploadFolder}/${SendFileName} ";

  # Clean curl files
  rm -f ./.headers ./.uploadoutputs;

# Credentials missing
elif [ -z "${UploadPassword}" ]; then<commit_msg>upload_basketbuilds: Remove unneeded configuration variables<commit_after>#!/bin/bash
TimeStart=$(date +%s);

# BasketBuild Upload Credentials
export UploadUserName='Username.s';
export UploadPassword='';

# Create  ~/.bash_android.basketbuild.**name**.rc with the exports to override the credentials
RemoteVariant="${3}";
if [ ! -z "${RemoteVariant}" ] && [ -f ~/.bash_android.basketbuild.${RemoteVariant}.rc ]; then
  source ~/.bash_android.basketbuild.${RemoteVariant}.rc;
elif [ -f ~/.bash_android.basketbuild.main.rc ]; then
  source ~/.bash_android.basketbuild.main.rc;
fi;

# Variables
SendFile="${1}";
UploadFolder="${2:-Development}";

# Notify and verify the upload
echo '';
echo -e " \e[1;33m[ Uploading to the server - User '${UploadUserName}' - Path '${UploadFolder}' ]\e[0m";
echo '';
if [ ! -z "${SendFile}" ] && [ -f "${SendFile}" ] && [ ! -z "${UploadPassword}" ]; then

  # File variables
  SendFileName=$(basename "${SendFile}");
  SendFileExt=${SendFileName##*.};
  SendFileSize=$(stat -c "%s" "${SendFile}");
  SendFileType='';

  # Uploading a zip
  if [[ "${SendFileExt}" =~ 'zip' ]]; then
    SendFileType='application/zip';
  fi;

  # Notify the file name
  echo "   File '$(basename ${SendFile})' uploading...";
  echo '';

  # Upload to BasketBuild through FTP
  ncftpput -R -v -t 10 \
           -u "${UploadUserName}" \
           -p "${UploadPassword}" \
           'basketbuild.com' \
           ${UploadFolder} \
           ${SendFile};

  # Detect failed FTP upload
  if [ ${?} -ne 0 ]; then

    # Fallback to WebUI upload
    notify-send "Failed uploading through FTP...";
    echo '';
    echo '   Failed uploading through FTP. Falling back to WebUI upload...';
    echo '';

    # Login to BasketBuild
    curl -L -# --dump-header .headers \
            -F "ftp_user=${UploadUserName}" \
            -F "ftp_pass=${UploadPassword}" \
            -F "openFolder=~${UploadFolder}" \
            -F "ip_check=1" \
            -F "login=1" \
            -F "login_save=1" \
            -F "submit=Login" \
            'https://s.basketbuild.com/webupload/' > /dev/null;

    # Upload to BasketBuild through WebUI
    curl -X POST -L -# --progress-bar -b .headers \
            -H "Cache-Control: no-cache" \
            -H "X-Filename: ${SendFileName}" \
            -H "X-Requested-With: XMLHttpRequest" \
            -H "X-File-Size: ${SendFileSize}" \
            -H "X-File-Type: ${SendFileType}" \
            -H "Content-Type: multipart/form-data" \
            --data-binary @"${SendFile}" \
            -o .uploadoutputs \
            'https://s.basketbuild.com/webupload/?ftpAction=upload&filePath=';

  fi;

  # Upload done
  echo '';
  echo -e "  \e[1;32mDownload :\e[0m https://basketbuild.com/filedl/devs?dev=${UploadUserName:0:-2}&dl=${UploadUserName:0:-2}/${UploadFolder}/${SendFileName} ";

  # Clean curl files
  rm -f ./.headers ./.uploadoutputs;

# Credentials missing
elif [ -z "${UploadPassword}" ]; then
{'fraction_non_alphanumeric': 0.18088851634534786, 'fraction_numerical': 0.007041072925398156, 'mean_word_length': 2.589651022864019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2241421', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1941, 'n_words': 449}